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
ifor
for, 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:
Instead, it just autocompletes:
if
, for
, etc. doen't even show up in autocomplete.
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
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:
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:
Selecting, for example, the "if - If Statement" choice from the menu will leave you with an appropriate snippet:
Similar snippets are available for various statements such as for
and while
, etc.