
Exploring our iOS toolbox - How to save values to UserDefaults & KeyChain in Swift

iOS
Every time I set up a new project, it took a full working day to get it ready for development. Until I discovered templates. Xcode templates have been around since the days of Xcode 4, but I only recently learned about them and they have completely changed the way I look at project creation. Try them with me and new projects will suddenly be that much more consistent and maintainable.
In the previous article about Xcode projet templates, I walked you through running this tool step by step and pointed out its benefits. This time I will introduce you to the additional capabilities of Xcode project templates, where when generating the project we will have a podfile ready with a pre-filled configuration. What that means in practice is that, after we generate new project, we enter the project via the console, we call
pod install
and the project will have pods configured. This will significantly reduce the configuration of the project and the style of the podfiles will be uniform when it comes to more complex podfiles.
The first thing to do is to create a new template, similar to last time, in the project templates folder with the .xctemplate extension
Here we will first create a Podfile file and insert the pods we want to import into each new project.
Note the variables used __VARIABLE_VERSION__ which sets the minimum project version below and __PACKAGENAME__ which sets the project name. When creating a project, __VARIABLE_VERSION__ will be the input parameter and __PACKAGENAME__ will be taken from the project name.
Then it is necessary to configure the TemplateInfo.plist file which represents the configuration of the template
Here it is essential to note the identifier variable
However, we now want to insert this template into our project template from the previous instructions.
The result will be as follows.
The only way these files differ is the ancestors key where we add the Identifier from the template we just created.
The only way these files differ is the ancestors key where we add the Identifier from the template we just created.