Question

I created a new Xcode Preference Pane project which I aim to run in the System Preference application. I have made one modification to the project's build settings:

  1. Changed Base SDK to Mac OS X 10.6 from 10.7 (Since I want to keep compatibility for Snow Leopard).

I have a nib file and NSPreferencePane subclass, yet Xcode doesn't allow me to run the application (only build it, the Run option is disabled).

My environment specs:

  • Macbook Pro 2010
  • Mac OS X Lion (10.7)
  • Xcode 4.2
Was it helpful?

Solution

With Xcode Schemes you can now do this very nicely. Edit the Run action of the scheme like so:

  • Set the Executable to System Preferences.app
  • Go to the Arguments tab and pass a launch argument: $USER_LIBRARY_DIR/PreferencePanes/$FULL_PRODUCT_NAME
  • Now expand the Run/Debug scheme and click on "Pre-actions"
  • Add a script pre-action with the following body: cp -a "$TARGET_BUILD_DIR/$FULL_PRODUCT_NAME" "$USER_LIBRARY_DIR/PreferencePanes/"

Bingo. Run will now launch System preferences and go directly into your prefpane.

By default, schemes are per-user and thus you are probably excluding them from your repository, and even if not other users won't see them. Go to "Manage Schemes..." and mark the prefPane scheme as shared if you want others to get these settings.

NB: For some reason I seem to get random crashes when you launch the prefPane as an argument. Just turn off the argument and manually launch once - from then on you can use the argument again...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top