Custom Xcode Template for Static Library in iOS

Where to store your templates?

Lets create some more folders…

  1. Kind: A string type used to identify the template type for example you use Xcode.Xcode3.ProjectTemplateUnitKind for project templates and use Xcode.IDEFoundation.TextSubstitutionFileTemplateKind file templates.
  2. Identifier: A unique identifier for a template. Used to uniquely identify a template or to inherit properties from ancestry templates more on that later.
  3. Concrete: A Bool type. Must be set to YES for Xcode to show your template when choosing a template for your project. If missing or set to NO Xcode treats the template as an abstract base template that other templates can inherit from.
  4. Ancestors: An Array type to hold a collection on Identifier, used to inherit from other templates.

Copying the default static template

  1. ___PACKAGENAMEASIDENTIFIER___: The Objc and Swift files are default files you get when you create a project based on the selected language. For a Swift static lib you obtain the ___PACKAGENAMEASIDENTIFIER___.swift and for Objc you obtain the .h and .m files. Macros are used as file names so they are replaced on project creation. For more info on what macro to use visit here.
  2. TemplateIcon.png: These are optional png files used to spice up your custom templates, so that its more recognisable.

Setting an identifier

Setting up swiftlint

<dict>
<key>Class</key>
<string>ShellScript</string>
<key>Name</key>
<string>Run SwiftLint</string>
<key>ShellPath</key>
<string>/bin/sh</string>
<key>ShellScript</key>
<string>$(git rev-parse --show-toplevel)/Tools/SwiftLint/swiftlint --path ${SRCROOT}</string
</dict>

Setting up Build Configuration

<key>Project</key>
<dict>
<key>Configurations</key>
<dict>
<key>Debug</key>
<dict/>
<key>Stage</key>
<dict/>
<key>AppStore</key>
<dict/>
</dict>
</dict>

A Software Engineer with a passion for technology. Working as an iOS Developer @BBC

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Ending the Build Infrastructure Nightmares

CarbonJ: A high performance, high-scale, drop-in replacement for carbon-cache and carbon-relay

What Are Progressive Web Apps (PWA), And Why You Should Consider Them

What Are Progressive Web Apps (PWA), And Why You Should Consider Them — Desuvit

Pinterest joins the Cloud Native Computing Foundation

Using The Contentful CMS In Angular

Why I Decided to Take a Depth Year

How to name your next open source project

Dependency Inversion Principle: How Google Developers write code

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
Melvin John

Melvin John

A Software Engineer with a passion for technology. Working as an iOS Developer @BBC

More from Medium

Continuations in Swift

[LeetCode] 2114. Maximum Number of Words Found in Sentences (Swift)

Clean Architecture in iOS

UISwitch Value Change Listener : Swift