Create Xcode Templates

Create Xcode templates to speed up our daywork and automatically create files and folders.

Davide Fin
Mar 3, 2020 · 12 min read
Photo by Joshua Sortino on Unsplash

Custom templates

Let’s start

Original Xcode TemplateInfo.plist for Swift File Creation
<key>Kind</key
<string>Xcode.IDEFoundation.TextSubstitutionFileTemplateKind</string>
<key>Description</key>
<string>An empty Swift file.</string>
<key>Summary</key>
<string>An empty Swift file</string>
<key>MainTemplateFile</key>
<string>___FILEBASENAME___.swift</string>

Build a new custom template

TemplateIcon@2x.png — 96 x 96 Icon
TemplateIcon.png — 48 x 48 icon
TemplateInfo.plist for my custom MVVM template
<key>Platforms</key>
<array>
<string>com.apple.platform.iphoneos</string>
</array>
<key>Options</key>
<array>
<dict>
<key>Identifier</key>
<string>productName</string>
<key>Required</key>
<true/>
<key>Name</key>
<string>Module:</string>
<key>Description</key>
<string>The name of the MVVM Module</string>
<key>Type</key>
<string>text</string>
<key>Default</key>
<string>MVVMModule</string>
</dict>
</array>
<key>Identifier</key>
<string>productName</string>
<key>Required</key>
<true/>
<key>Name</key>
<string>Module:</string>
<key>Description</key>
<string>The name of the MVVM Module</string>
<key>Type</key>
<string>text</string>
<key>Default</key>
<string>MVVMModule</string>
Xcode: file creation window with our custom category and MVVM template.
___FILEBASENAME___ViewController.swift
___FILEBASENAME___ViewModel.swift

What comes next

References

OverApp • iOS

The OverApp iOS Dev Magazine

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store