Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to share code snippets among several installations of Xcode?

Tags:

xcode

xcode4

Based in part on the advice in this response to a question on SO, I tried replacing /Developer/Library/Xcode/PrivatePlugIns/IDECodeSnippetLibrary.ideplugin with an alias to an exact copy in a Dropbox folder, but doing so caused Xcode 4.2 to crash due to an internal logic error.

I want to sync the snippets on my work and home machine. Right now I'm using Alfred for snippets, but it'd be nice to have Xcode handle the snippets, for convenient tab jumping and intellisense. Has anyone out there attempted something similar?

like image 362
modocache Avatar asked Sep 24 '11 11:09

modocache


People also ask

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 .

How do code snippets work?

So, What is a Code Snippet? "Code Snippet" is a term used to describe a small portion of re-usable source code, machine code, or text. They allow a programmer to avoid typing repetitive code during the course of routine programming.


2 Answers

I guess sharing your own (not the system) snippets is fine. Then, try replacing ~/Library/Developer/Xcode/UserData/CodeSnippets with a symbolic link to your shared folder.

Something like: (in Terminal app)

cd ~/Library/Developer/Xcode/UserData
mv CodeSnippets /path/to/shared/folder/
ln -s /path/to/shared/folder/CodeSnippets CodeSnippets

Repeat in any Mac in which you want to access shared snippets.

like image 182
djromero Avatar answered Sep 30 '22 00:09

djromero


as i do and it work.

simply copy your code snippets in

~/Library/Developer/Xcode/UserData/CodeSnippets/

if your didn't made any custom code snippets before then you have to copy whole 'CodeSnippets' dir to path

~/Library/Developer/Xcode/UserData/

now simply close the xcode from activity monitor and start it again you will get new code snippets.

/ use the following code to show hidden file / apply this command one by one in teminal

defaults write com.apple.Finder AppleShowAllFiles TRUE

killall Finder

like image 27
utkal patel Avatar answered Sep 30 '22 02:09

utkal patel