Skip to content

🗂️ This repository provides a guide to creating Xcode templates for iOS boilerplate code to save time and increase creativity in development. It simplifies the process and helps new team members get up to speed. A solution to Xcode's poorly documented templates.

License

Notifications You must be signed in to change notification settings

GoodRequest/Temple

Repository files navigation

🕍 Xcode templates

iOS Version Swift Version

If you are like me you love writing iOS code but there is nothing that breaks your creativity more than boilerplate code and having to think about it while some other more creative solutions might reside in your mind at the same time. Even if you have a pretty good idea about your architecture it is surely a waste of time to write boilerplate since it’s just repeating code. All you need is a bunch of good templates and writing code in any architecture should be easier for you as well and easier to get into for new members of the team. But it has a catch. Xcode templates aren’t exactly what you would call a well-documented part of the tool. That is why I decided to bring you through the process of building these from scratch to save you the trouble I went through with collecting the knowledge on this subject.

Writing templates has these advantages:

  • Makes you save time in the long run if you take time to maintain and write your templates well
  • It takes less time to onboard new people because they will not work from scratch
  • It helps maintain code conventions that you set up for yourself and your team
  • If you ever wanted to export your snippets you’ll notice one similarity with templates and that is that they are saved locally and outside of any project that you are working on. That means that it's a great opportunity to upload those to a repository to be able to share them or to change your workstation while keeping up to date.

Table of content

#warning: all templates are dependent on GoodrequestIOSExtensions, that you can fetch with SPM from: https://github.com/GoodRequest/GoodIOSExtensions

Installation

First of all if you want to connect template to your template list you have to find the right folder to clone the repo. Directory where you can add custom templates so they are visible in your template list in xcode:

/Users/$USER_NAME/Library/Developer/Xcode/Templates

Git clone

Go to the folder and clone the the git repo contents

/Users/$USER_NAME/Library/Developer/Xcode/Templates

Copy paste

Alternativelly you can copy the project templates and paste thme in the folder

/Users/$USER_NAME/Library/Developer/Xcode/Templates

Create your own templates

Also if you want to create your own take inspiration from the already existing ones. Directory where to find already existing Xcode templates to take inspiration from:

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/File

Loading Dependencies with SPM

The template automatically generated build tools package. What you want to do now is to connect it to the project as a local package.

  1. Open the Package.swift you your project root and uncomment the package.swift. This will cause a compile error, but only because its still now added as a defacto package despite the fact that it is already in the right place in the project.

  2. Delete the reference to these two package files.

  3. Now you want to add a local package of good dependencies. Open the add package prompt for the project and click add local project. Point to the packages folder in the project root and find good dependencies. Once you select them hit add package and you are good to go Logo

  4. As soon as the packages are fetched add the package as framework

Logo

External Dependencies

All external dependencies should be primarily added via SPM via a local package or the projects package interface. It’s up to you which method you choose.

License

GoodIOSExtensions repository is released under the MIT license. See LICENSE for details.

About

🗂️ This repository provides a guide to creating Xcode templates for iOS boilerplate code to save time and increase creativity in development. It simplifies the process and helps new team members get up to speed. A solution to Xcode's poorly documented templates.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages