iOS tips: Creating custom code snippets in xCode

How to create custom code snippets in xcode? Its super easy.

Image for post
Image for post
stocksnap.io

Whenever you find some useful code that you can reuse in xcode, do create a code snippet. Code snippets appear towards the right bottom corner of xcode (under the utilities section).

Image for post
Image for post
code snippets

There are so many pre defined code snippets in xcode. You just have to drag the required snippet to your editor area and use it. Sometimes you may have to edit some variable names and all as per your code. Its very much helpful in programming.

How to create a code snippet in xcode?

Creating a code snippet is easy. Just select the code that you want to make a snippet and drag it to the code snippet section towards the bottom right of the xcode. A window will appear and there you can rename it and add a description. Check the gif below.

Creating a code snippet

Now the code snippet is created. Just drag the code snippet from the snippet section to the editor area . Thats it.

Image for post
Image for post
Using the code snippet

But if you need to create some code placeholders, you can edit the code snippets you just saved and add the code placeholders. Placeholders should be written like :

let const = <# placeholder_text/code #>

Have a look at the gif below:

Image for post
Image for post
Creating snippets with code placeholders

Thats it.!!

Enjoy!!

If you enjoyed reading this post, please share and give some clapps so others can find it πŸ‘πŸ‘πŸ‘πŸ‘πŸ‘ !!!!

You can follow me on Medium for fresh articles. Also, connect with me on LinkedIn. Also follow my facebook page on swift: iosswiftblogger.

If you have any comment, question, or recommendation, feel free to post them in the comment section below!

Written by

iOS and tvOS developer, dreamer, photographer 🀨

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