如何在 xcode 项目中启用/禁用 ARC?
如果创建的项目已禁用 ARC,我该如何启用它,反之亦然?
If a project has already been created with ARC disabled, how do I enable it and vice versa?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
打开您的项目并选择编辑 ->重构->转换为 Objective-C ARC。
这将开始检查您的代码是否已准备好进行转换。
另请参阅 Clang 文档:Objective-C 自动引用计数 (ARC)
如何禁用 ARC已在此处得到解答
Open your project and select Edit -> Refactor -> Convert to Objective-C ARC.
This will start checking your code if it is ready for the conversion.
See also Clang documentation: Objective-C Automatic Reference Counting (ARC)
How to disable ARC has been answered here
以下是我所做的步骤,它对我有用
Project
Targets
Build Settings
Apple LLVM 编译器 3.0 - 语言
和Objective-C 自动引用计数
,并在所有三个部分中选择NO
。Following are the steps which I did and it worked for me
Project
Targets
Build Settings
Apple LLVM compiler 3.0 - Language
andObjective-C Automatic Reference Counting
and selectNO
in all three sections.当您迁移项目以使用 ARC 时,-fobjc-arc 编译器标志将设置为所有 Objective-C 源文件的默认值。您可以使用特定类的 -fno-objc-arc 编译器标志来禁用该类的 ARC。在 Xcode 的目标“构建阶段”选项卡中,打开“编译源”组以显示源文件列表。双击要设置标志的文件,在弹出面板中输入 -fno-objc-arc,然后单击“完成”。
When you migrate a project to use ARC, the -fobjc-arc compiler flag is set as the default for all Objective-C source files. You can disable ARC for a specific class using the -fno-objc-arc compiler flag for that class. In Xcode, in the target Build Phases tab, open the Compile Sources group to reveal the source file list. Double-click the file for which you want to set the flag, enter -fno-objc-arc in the pop-up panel, then click Done.
在 Xcode 5.0.2 中,在 Navigatior 中选择您的项目,选择“构建设置”,搜索 Apple LLVM 5.0 - Language - Objective C 并将 Objective-C 自动引用计数更改为 NO
In Xcode 5.0.2, select your project in Navigatior, select Build Settings, search for Apple LLVM 5.0 - Language - Objective C and change Objective-C Automatic Refence Counting to NO