September 4, 2009 - Tags: ,

Xcode Tips

I spend quite some time with Xcode lately. So this is partly a reminder for myself.

  • When you create new class files the default template’s header comment includes a __MyCompanyName__ placeholder. The only way to configure it seems to be issuing this command in Terminal:
    defaults write com.apple.Xcode PBXCustomTemplateMacroDefinitions '{"ORGANIZATIONNAME" =   "brosinski.com";}'
  • CTRL+2 opens the symbol dropdown so you can quickly switch between functions
  • Inserting #pragma mark allows you to add grouping descriptions to the symbol list, TODO: comments also show up there
  • Option + Command + up switches between header and implementation file
  • Here is a nice cheat sheet for all Xcode keyboard shortcuts

You can also re-create your favorite key bindings by creating a file called PBKeyBinding.dict  in ~/Library/KeyBindings/ and adding something like this:

{
    "^$K" = (
        "selectLine:",
        "cut:"
    );
    "^$D" = (
        "selectLine:",
        "copy:",
        "moveToEndOfLine:",
        "insertNewline:",
        "paste:"
    );
}

This will enable CTRL+SHIFT+K to kill a line and CTRL+SHIFT+D to duplicate a line. Here is a nice description of how this system works.

(C) 2008 - Stephan Brosinski - All Rights Reserved