Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apple PrefPane example fails to build with clang error objecting to both -fobjc-arc and -fobjc-gc

I'm trying to build a preference pane as a part of learning OS X development. After downloading Apple's preference pane example code and trying to build the project I get the following error:

clang: error: cannot specify both '-fobjc-arc' and '-fobjc-gc'

Turning off garbage collection in Build Settings allows the project to build properly, but once the preference pane example is installed on the local machine it won't start saying,

"You can’t open PrefsPane preferences because it doesn’t work on an Intel-based Mac."

I've tried every combination of architecture (10.6, 10.7) and Objective-C Automatic Reference Counting (Yes, No) and Objective-C Garbage Collection (Supported (-fobjc-gc), Unsupported, Required (-fobjc-gc only) available. While some combinations do allow the project to build, I can't get the preference pane to load.

What are the proper architecture, ARC, and GC settings necessary to build and deploy a preference pane for OS X 10.7 using Xcode 4.3.2?

like image 881
Mark Nichols Avatar asked Jan 17 '23 22:01

Mark Nichols


2 Answers

PrefsPane built with garbage collection turned off and ARC enabled in build setting works on Mac OS X 10.8.2. "System Preferences.app" just shows a message:

    To use this preferences pane, System Preferences must quit and reopen.

It's because System Preferences is started with garbage collection enabled by default and if it tries to open a preferences pane without GC it should be restarted without GC too. So ARC can be used on 10.8 to develop preferences panes.

like image 63
Ostap Avatar answered Apr 29 '23 11:04

Ostap


I just stumbled upon this myself. So turns out (accoridng to Apple dev docs):

All 64-bit preference panes are expected to use garbage collection. Using garbage collection will, in most cases, simplify your code and reduce the likelihood of memory leaks.

In Snow Leopard, the System Preferences application will run 64-bit preference panes with garbage collection enabled, and 32-bit panes with garbage collection disabled.

For more info go to Updating Preference Panes for Snow Leopard and Beyond.

So you can't use ARC. Only GC.

like image 31
Nikolozi Avatar answered Apr 29 '23 10:04

Nikolozi