Debugging System Preference Panes with ARC under Mountain Lion
First of all, follow the accepted answer in this StackOverflow question. That takes care of the basics. Second, if your application is using ARC (as it should if it targets Lion and higher) you may have to explicitly disable garbage collection for the System Preferences application. System Preferences is using ARC by default but there seems to be some crutch in place that causes it to switch to GC when launched by Xcode. This crutch will cause
Garbage Collection enabled !
in the debug log and the
To use the “...†preferences pane, System Preferences must quit and reopen.
error sheet to be displayed when your preference pane is selected. Clicking OK will restart System Preferences and you will lose your debug session.
I found that setting OBJC_DISABLE_GC
to YES
will override the crutch and cause System Preferences to start with ARC enabled, letting you debug your preference pane as intended. In Xcode, edit the scheme (Menu Product - Edit scheme), select the Run action and click the arguments tab. To the Environment Variables list, add an entry for OBJC_DISABLE_GC
and YES
.
This is on Xcode 4.5.2 (4G2008a) on OS X 10.8.2.