How can one save / restore user created code snippets in Xcode?
User's code snippets are saved in '~/Library/Developer/Xcode/UserData/CodeSnippets' in the form of xml documents with 'codesnippet' extension.
There are various ways you can store a code snippet, either by keeping it in a GitHub repository or can use a smart code snippet manager, like Codiga's Coding Assistant. Coding Assistant allows you to store and reuse code snippets.
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.
Code Snippet Library is a public library that contains an extensive searchable collection of snippets in various programming languages: HTML, Javascript, PHP, Terminal, SQL, WordPress, API.
The user generated code snippets are saved in
~/Library/Developer/Xcode/UserData/CodeSnippets
And you can simply pass them around to save and restore them. I recommend giving them a meaningful name instead of the generated one.
I wrote a short explanation about it here, and also started a collection of useful code snippets that can be shared on github. There are still very little snippets there, so any useful snippets you have to share would be great.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With