Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding code snippet in Code Snippet Library (Xcode 10)

Recently when I was using Xcode 10 beta 3, I tried to make a code snippet and add it to the code snippet library.

But the drag drop cannot be done as the code snippet library is detached in Xcode 10, and hides when I click on a code.

How to add code snippet in code snippet library in Xcode 10?

like image 955
Subhajit Halder Avatar asked Jul 09 '18 08:07

Subhajit Halder


People also ask

How do I add a code to snippets?

With a code file open in the editor, choose Snippets > Insert Snippet from the right-click menu, then My Code Snippets. You should see a snippet named Square Root. Double-click it. The snippet code is inserted in the code file.

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 .

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.


1 Answers

After some time found out.

Select the code you want to add to library. Right-click on it and click on Create Code Snippet from the pop-up menu.

Apparently upto Xcode 9.x.x, this option was not there.

enter image description here

like image 139
Subhajit Halder Avatar answered Oct 04 '22 17:10

Subhajit Halder