苹果PrefPane示例无法构建与clang错误反对-fobjc-arc和-fobjc-gc [英] Apple PrefPane example fails to build with clang error objecting to both -fobjc-arc and -fobjc-gc

查看:558
本文介绍了苹果PrefPane示例无法构建与clang错误反对-fobjc-arc和-fobjc-gc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个偏好窗格作为学习OS X开发的一部分。在下载Apple的首选项窗格示例代码,并试图构建项目我得到以下错误:



clang:error:不能同时指定'-fobjc-arc '和'-fobjc-gc'



在构建设置中关闭垃圾收集可以正确构建项目,但是一旦在本地机器上安装了首选项窗格示例不会开始说,

您无法打开PrefsPane首选项,因为它不能在基于Intel的Mac上运行。



我尝试了架构(10.6,10.7)和Objective-C自动引用计数(是,否)和Objective-C垃圾收集(支持(-fobjc-gc),不支持,必需(仅限-fobjc-gc)可用。虽然一些组合允许项目构建,但我无法获得加载首选项窗格。



解决方案

使用Xcode 4.3.2为OS X 10.7构建和部署首选项窗格所需的架构,ARC和GC设置我只是偶然发现了。所以,结果是(根据苹果dev文档):


所有64位首选项窗格都需要使用垃圾回收。在大多数情况下,使用垃圾回收将简化您的代码并减少内存泄漏的可能性。



在Snow Leopard中,系统首选项应用程序将运行64位首选项窗格已启用垃圾回收,以及禁用垃圾回收的32位窗格。


有关详细信息,请转到更新雪豹和超越的偏好平面



所以你不能使用ARC。只有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?

解决方案

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.

这篇关于苹果PrefPane示例无法构建与clang错误反对-fobjc-arc和-fobjc-gc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆