Speed up development with Xcode Snippets

Riccardo Cipolleschi
The Startup
Published in
4 min readApr 29, 2020

--

Hi everybody, I’m Riccardo. Senior iOS Engineer at Bending Spoons, I breathe iOS development, both apps and tools and I love to share my knowledge with others.

Hi everybody, today I’d like to share a trick I use to save time while developing. It’s useful when I write several pieces of code whose structure is repetitive (Test skeleton, Views, Dispatchables, Pattern, …): I write it once and then I save it as an Xcode snippet to reuse it later.

How to create a Snippet

The creation of a snippet in Xcode is extremely easy.

First of all, write the piece of code that you want to save as a snippet. For example, let’s write the ViewModel and the View of a screen of your app:

All the views and view models we have to write share this common structure. The only things that we have to change are the names of the view and the names of the view model. This structure is a great candidate to be saved as a snippet.

To do so, just select all this code and right-click on it. Choose Create Code Snippet from the contextual menu. The following screen will appear:

--

--

Riccardo Cipolleschi
The Startup

Hey there, I’m Riccardo. Software engineer at Meta. I have a passion for iOS and I love to share my knowledge with others.