Xcode built-in snippets edit

前端 未结 6 1340
既然无缘
既然无缘 2020-12-13 19:56

Is there a way to edit Xcode\'s built-in snippets? There is an edit button, but pressing it doesn\'t seem to allow changing the snippet\'s text.

Any insight is appr

6条回答
  •  半阙折子戏
    2020-12-13 20:33

    You can edit the Xcode system snippets using a text editor and knowing the location of the system code snippets file. In Xcode 5.1.1 the location of the system code snippets file has changed once again to:

    /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/SystemCodeSnippets.codesnippets

    and you must have root privileges to edit the plist file in place because its owner and permissions are as follows:

    $ ls -l /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/SystemCodeSnippets.codesnippets
    -rw-r--r--  1 root  wheel  190 May 16 18:23 /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/SystemCodeSnippets.codesnippets
    

    The plist dictionary keys are pretty self-explanatory and for the IDECodeSnippetIdentifier key, you can generate UUIDs yourself using for example the command:

    $ uuidgen
    42F6B133-5DA3-41DB-8874-4E10E447F723
    

    Once you've edited the file using for instance sudo and your editor of choice, you have to restart Xcode in order to pick up your changes.

    Happy hacking!

提交回复
热议问题