Depression and Single Motherhood Made Me A Shitty Friend

Since I began writing daily at the end of April, I’ve crossed paths with more new people than I have in the past decade. Maybe even longer. There’s no easy way to say this, but depression began to…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Create Xcode file templates and share them with your team

New files that match your preferred coding style

Something all Xcode users will be familiar with is the process of creating new files. When the new file command is triggered, we are presented with a window containing a selection of templates to base our new file upon. These new templates often contain lines of code we immediately delete or code that needs to be changed to fit into our preferred style.

Many people may be unaware that instead of relying solely on the provided templates, we can create our own and have Xcode present them to us. This can simplify the process of creating new files and allow them to match more specific requirements.

The process of creating templates can seem a bit confusing at first, but the end result can be really useful. We are going to explore the process of writing our own Xcode file templates, before delving into how we might go about sharing these with other developers on a particular project.

A sheet of paper with pencils, rubber and light bulb sitting on it.
Prepare the template

When Xcode launches, it looks for file templates within a specific location: ~/Library/Developer/Xcode/Templates/File Templates. To get started, we need to create a directory within here that will house all of our file templates.

Within this directory, a quick way to get started is by copying one of the built-in templates and then altering it. They can be found within the Xcode application bundle, with a good option for Swift-based templates being the one for a new Swift file, Source/Swift File.xctemplate.

After copying the files, we find the xctemplate contains 4 different files.

Add a comment

Related posts:

Benefits of Computer Annual Maintenance Contract

With the advent of information technology, the scenarios of businesses are changing day by day. Once the industry entirely relies on physical infrastructure but now it is more about IT…

Work life balance and Fantasy Premier League

The new Premier League season started this weekend, and along with it the Fantasy Premier League that I take part in with friends. The Fantasy Premier League is a simple concept. You pick a team of…

Blue Pill or Red Pill?

Everyday brings new choices — the past couple weeks have been no different. While we have been wrapping up our back-end fundamentals, there has been a heavy decision weighing on me: Our choices were…