Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Xcode default snippets (if, for, struct etc.) not showing in autocomplete

I am new to Swift and also Xcode. In many tutorials I can see that snippets are really usefull especially for the beginners like me. Unfortunately I cant use them. When I am typing something, for example iforfor, nothing shows up in the autocomplete section. Or if it does (like for struct`) when I hit enter it just autocompletes my word.

I want it to look like this:

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Instead, it just autocompletes:

enter image description here

if, for, etc. doen’t even show up in autocomplete.

enter image description here

I couldn`t find a solution. Any help would be really useful.

I basicly want it to work like this https://sarunw.com/posts/how-to-create-code-snippets-in-xcode/#using-xcode-snippets

>Solution :

First, make sure the proper settings are enabled in Xcode. Go to Xcode -> Preferences (or Settings depending on your version of macOS). Then select the "Text Editing" tab. Then select the "Editing" sub-tab. Ensure the "Suggest completions while typing" option is enabled.


While typing in Xcode, begin typing the struct keyword but don’t press return. You should see the following:

enter image description here

By selecting the "struct – Struct" choice from the menu, you will end up with desired code block snippet.

This also works when you want to add a code snippet for an if statement. Begin by typing if (make sure you are entering this in a valid context for an if block). Xcode will display appropriate choices:

enter image description here

Selecting, for example, the "if – If Statement" choice from the menu will leave you with an appropriate snippet:

enter image description here

Similar snippets are available for various statements such as for and while, etc.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading