Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add/remove custom Code snippets in Xcode 11 and above

Tags:

ios

xcode10

How to drag and drop a custom code to code snippets and use a shortcut text for auto-fill as we did in Xcode < 10

enter image description here

And how to remove the snippets?

like image 778
Saranjith Avatar asked Sep 20 '18 04:09

Saranjith


People also ask

How do I add a code snippet in Xcode 12?

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.

How do I use code snippets in Xcode?

If you want to create a new code snippet in Xcode, you just need to select a portion of code, right-click on it and choose the option Create code snippet. Then, you can edit and delete it by pressing cmd + shift + L .

Where are Xcode snippets stored?

Code snippets are stored in your ~/Library/Developer/Xcode/UserData/CodeSnippets directory. To share your code snippets, simply copy them from this directory. Each code snippet file is a standalone plist file with a universally unique identifier (UUID) as the file name followed by .


3 Answers

How to add


In Xcode select line or code to be added in code snippet and then

Option1

  1. Goto Editor

  2. choose the Create code snippet

enter image description here

Option 2

Select Code you want to add to snippet right click and choose create code snippet

How to Remove


Choose any snippet and press backspace enter image description here


How to Edit


If you want to edit already added code snippet it is easy. just open code snippet library list (from right corner) from the list select code snippet you want to edit and press SPACE BAR button

enter image description here

Warning : My Xcode crashes randomly couple of time during removing or adding code snippet make sure you save your work (Xcode 10 BUG) :]

Hope it is helpful

like image 99
Prashant Tukadiya Avatar answered Sep 21 '22 22:09

Prashant Tukadiya


Update for Xcode 11

Add code snippet

Same way as before:

  1. Select code
  2. Right click on it
  3. Create Code Snippet

Edit and Delete code snippet

Type cmd + shift + L and you will see the following UI:

enter image description here


For more information about Xcode code snippets check this article.

like image 43
Matias Jurfest Avatar answered Sep 22 '22 22:09

Matias Jurfest


To add new code snippet in XCODE 10, you can just:
- select the codes that you want to create snippet
- then right-click on those selected codes
- choose Create code snippet.

enter image description here

And to remove the code snippets:
- Just click on the {} icon on the top right nav
- Then select on the code snippet you want to delete
- Press Backspace

enter image description here

like image 26
KoingDev Avatar answered Sep 18 '22 22:09

KoingDev