Using Custom Code Snippets
When you find yourself using the same pieces of code over and over again, it is often helpful to create a custom Code Snippet!
Step 1: Create a Custom Code Snippet
In current Xcode the Code Snippet Library is no longer a panel docked in the Utilities pane — it lives in the Library window that you summon over the editor.
- Highlight the code you want to save in the editor.
- Right-click the selection and choose Create Code Snippet… (equivalently, Editor → Create Code Snippet).
- In the snippet editor that appears, give the snippet a Title, optional Summary, and a Completion Shortcut. The shortcut is the prefix you’ll type to expand the snippet later — pick something short and memorable.
- Click Done to save.

Step 2: Access a Custom Code Snippet
There are 2 easy ways to access your custom code snippet.
- Type in the completion shortcut and let Xcode autocomplete the rest.
- Open the Library window (View → Show Library or ⇧⌘L, or the
+button at the top-right of the editor toolbar), switch to the Code Snippets tab, then drag the snippet into your file.
