Photo by Christin Hume on Unsplash

How to Boost your iOS App development process

Giorgi Sandroshvili
Level Up Coding
Published in
7 min readMay 10, 2022

--

iOS App development is an alluring process.
The work includes stages of:

  • Research
  • Design / Architecture
  • Development
  • Test
  • Deployment
  • Maintenance

Well, while mainly those processes are quite interesting and challenging, as time passes, the more experience you gain. Some parts of the job become routine. I assume you agree with the idea that writing routine code or designing routine solutions are not the essence of development that we love. So, when times like this come, we have to turn geeky instincts on. It’s time to automate those kinds of work and leave more space for the things that might be essential for us.

There are numerous ways one can speed up coding, for example, mastering debugging tools will save you days or months of trying to solve some bugs. In addition, there is a wide range of tools or skills that will make your life easier in coding. But today, I will discuss three basic yet essential tips that will comfort your coding process.
The topics will be:

  • Xcode Shortcuts
  • Code Snippets
  • Xcode Templates

If you are not familiar with those topics, you will have a general idea of speeding up your coding, when, where, and how to use shortcuts, snippets, and templates after reading this article. Alright, let’s dive into Xcode Shortcuts at first.

Xcode Shortcuts

Take a few seconds to think of when was the last time you used the Run button in your Xcode IDE. If this is not your first step in iOS Development, I hope you don’t remember when you tapped that button lately, as there is ⌘ + R shortcut to run your project. However, if you still tap that run button and are on your first steps in iOS Development, I have some gold mine to share with you.

Xcode is the IDE that we “love”, and it’s no surprise that Xcode “loves” us as well. It’s not even 10 minutes you try to enjoy your code and build it when some random error comes in. That’s the time when we make what’s called a PRO developer move, copy the error and google it. Open up the first StackOverflow page, and in the answers section (And when I say answers section, I mean answers section!!) we see the hero of ours. The one who has a magic wand in his/her hand and magical three words — Clean build Folder. You go back to your project, tap that magic Shift + ⌘ + K keys, and the issue is gone.

I intend with those two examples to show you that there are some shortcuts that you already use in your daily coding. You might even forget where that Run button is as the time passes. If you invest some time learning those shortcuts, there are tons of them. In just a few weeks, you will see improvement and a feeling of home in your Xcode environment.

Let’s look at the example below to see the time differences between the two gifs that show the same outcome.

Without shortcut

With shortcut

You can select lines like that, with your option key, and mouse pointer. As you can see, a simple, basic shortcut can make your coding 3–4x faster. There are tons of shortcuts that you can use in Xcode, And I’m not going to go through them all in this article. But if you get the idea of what benefits it gives, you can search for some of them. It’s quite easy to get them. From there, we can move to Code Snippets.

Code Snippets

A Code Snippet is a reusable block of code that can be used throughout different projects. Snippets can be basic configurations of ViewController, programmatic setup of UI Components, or solutions for issues. They can be almost anything reusable and helpful to store.

Writing consistent code is one of the critical components of good software. Unfortunately, consistency often requires boilerplate code to be written in some project parts. So, why should we write that code from the ground when we can create reusable Code Snippets.

Let’s take a look at Switch Code Snippet in Xcode

As you see, the code you might have used a lot of times is actually a Code Snippet built in Xcode. It makes implementing a switch statement easier, comfortable and faster for you. And now, with its auto-completed cases switch statement, Code Snippet is quite a powerful tool. To see more of the code snippets, you can jump right into the Xcode, open up .swift file, and with the shortcut Shift + ⌘ + L, Snippets Library opens up. You can use the exact same shortcut in .xib and storyboard files to reach UI Library.

Alright, as we already have seen how to search for some snippets, now let’s find out how to create one on our own.
Select the reusable code -> Right-click on your mouse -> Create Code Snippet..

In the Title field, you enter your Code Snippet’s title and use it in your code. Then, you have to give it Completion. So in the Completion, you enter the text that you will type so that Code will be autocompleted. In case you need to create placeholders in your snippet. You can write it like this <#yourPlaceholder#> so that when using that code snippet, you can switch through placeholders with the Tab key.

Xcode Templates

Have you ever created a project in Xcode? It’s quite an intuitive process. You open up Xcode, click Create new Xcode Project, select the platform, enter the name, and the sample project is already there. In the case of UIKit, it contains AppDelegate, SceneDelegate, ViewController, Main, Assets, LaunchScreen, and info.plist files. So, how did they end up here when we haven’t created them one by one. The answer is that when you create a project from scratch, it uses a project template. We get that by default to create projects for different devices with ease.

There are times when we use the same essential modifications in the new project, so we can build upon our changes. For example, we may add CoreData services, networking, or any basic work you need to do when the project is created. In that case, you can create your Project Template. So, whenever you start your new project, you don’t have to copy items from previous projects and make some changes there. You click create a new project, and your template will appear there, just like the image below.

How to create a project template?

Open up Finder, click Go to folder and enter the location — /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/iOS

There you can see default iOS Templates, those are the templates that are used to create your projects in Xcode. If you want to check templates for macOS or watchOS or anything else, you can look around Xcode/Templates Folder.

Let’s create an iOS Template project after moving to the iOS Project Templates folder. You will see different samples made there.

In the Application folder, you’ll see App.xctemplate, you can copy that basic template. After that, open finder, click Go to folder and enter the location —/Library/Developer/Xcode/Templates In that folder, you can create your own folder and paste App.xctemplate there.

Here we can add some files that we want to have in our sample project. To make it work, we have to modify the Identifier in TemplateInfo.plist file and set it to some unique value.

Congratulations, we are done with Project Templates. But, this is not the end. You might not want to create a new project always to build your basic setup. In case we need to add some particular files to an existing App, we can create File Templates.

When you tap ⌘ + N in your project, it opens up the file templates window, where you see default templates from Xcode.

Let’s create our Swift File template.
At first, we open up Finder, click Go to folder, and enter location — /Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File Templates/MultiPlatform/Source There is Swift File.xctemplate folder and let’s copy that. Then we move to ~/Library/Developer/Xcode/Templates and create a new folder there, in the folder we paste Swift File.xctemplate. You can change the Folder name to your desired one. open up the folder and there is .swift file, which you can open up and modify to get your reusable code. This is it, you have created your first File Template, you can check it in Xcode, ⌘ + N scroll to end.

If you want to get more in-depth knowledge about Templates and how to make them more advanced, you can search for some articles and master them 🚀.

Conclusion

In this article, we have discussed the essence of Xcode Shortcuts, the usage of Code Snippets, and the Basics of Xcode Templates. Advancing those skills will boost your productivity a lot.

--

--