Give your simulator superpowers

RocketSim: An Essential Developer Tool
as recommended by Apple

Using Xcode custom file templates with GIT

Xcode custom file templates are a great way to develop just a bit faster and enable you to define a base template with all repetitive work included. Combining it with GIT enables you to share these files in your team and let them benefit as well.

Creating a GIT repository for Xcode custom file templates

User-defined templates for Xcode are located in ~/Library/Developer/Xcode/Templates/File Template. If such folder is missing you can create it yourself and Xcode will be linked to it upon restarting. Subfolders can be used to create a custom header for your templates.

Create a subfolder for your GIT repository and use this new location for your custom templates.

Xcode Custom File Templates

Xcode Custom File Templates

Stay updated with the best of Swift & SwiftUI

Join over 20,003 Swift developers in SwiftLee Weekly for exclusive tips and updates. Don’t miss out – subscribe now:

You can always unsubscribe, no hard feelings.

Create your first custom file template

There are lots of great resources to learn how to create your own custom file templates. Some examples are:

But for me, the easiest way is to copy a base template from Xcode which I’m already familiar with. You can find them easily by opening the terminal and execute the following line for generic templates:

open /Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates

Or the following line for platform specific templates, replacing #platform_name# with the platform you want to explore:

open /Applications/Xcode.app/Contents/Developer/Platforms/#platform_name#/Developer/Library/Xcode/Template

You can push your changes to the GIT repository after you’ve created your first custom file template. Your team will be able to make use of them by fetching the latest changes.

 
Antoine van der Lee

Written by

Antoine van der Lee

iOS Developer since 2010, former Staff iOS Engineer at WeTransfer and currently full-time Indie Developer & Founder at SwiftLee. Writing a new blog post every week related to Swift, iOS and Xcode. Regular speaker and workshop host.

Are you ready to

Turn your side projects into independence?

Learn my proven steps to transform your passion into profit.