I've got some user code snippets in my Xcode 4 which I would like to copy to another machine and share with other developers. Is there a way to do so?
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 .
Paul Hudson @twostraws. SE-0356 introduces the concept of snippets, which are designed to fill a small but important documentation gap for projects: sample code bigger than simple API documentation, but smaller than an example project, designed to show off one specific thing in your project.
Ah found it, they are saved at:
~/Library/Developer/Xcode/UserData/CodeSnippets/
Each one is a plist file. In contrast to Xcode 3 there is now one file per snippet. There is no harm done in renaming them to more useful file names, Xcode will not mind. In fact, my whole CodeSnippets folder is a git repository and many devs share their favorites on github. Mine are at https://github.com/lichtschlag/Xcode-4-Code-Snippets.
As noted by NSSplendid, they're stored in ~/Library/Developer/Xcode/UserData/CodeSnippets/
.
You can use Dropbox to sync them; I use this technique to synchronize my key bindings and archives between computers.
Follow these steps:
~/Dropbox/CodeSnippets
ln -s ~/Library/Developer/Xcode/UserData/CodeSnippets ~/Dropbox/CodeSnippets
.On your other computer:
rm -R ~/Library/Developer/Xcode/UserData/CodeSnippets
.mv ~/Dropbox/CodeSnippets ~/Library/Developer/Xcode/UserData/CodeSnippets
.ln -s ~/Library/Developer/Xcode/UserData/CodeSnippets ~/Dropbox/CodeSnippets
.The convolutions are necessary because Xcode will not follow a symlink, but Dropbox will. Dropbox will treat that symlink exactly as if the directory was actually there.
This is not perfect; you will probably have to quit Xcode to have it recognize new snippets.
I sync my entire UserData directory, which gets me synchronized key bindings, named tabs, font & color schemes and code snippets. To do this, move and ln ~/Library/Developer/Xcode/UserData instead.
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