如何从 XCode 中删除 ARC
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8958761/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to remove ARC from XCode
提问by Ashish Agarwal
I have already created a project in XCode 4.2 with ARC checked. The problem is that I have to download and add the ASIHttpRequest files. This is giving a whole bunch of errors when I try to compile. Is there some way to fix this (other than to create a project again) ?
我已经在 XCode 4.2 中创建了一个项目,并选中了 ARC。问题是我必须下载并添加 ASIHttpRequest 文件。当我尝试编译时,这给出了一大堆错误。有没有办法解决这个问题(除了重新创建一个项目)?
回答by Louis
Click on the name of the project on the navigation view in the left side, go to Targets -> Build Phases and add -fno-objc-arcto the "compiler flags" for any relevant files.
单击左侧导航视图上的项目名称,转到目标 -> 构建阶段并将-fno-objc-arc添加到任何相关文件的“编译器标志”。
回答by MyztikJenz
You can turn off ARC per-file by passing the flag -fno-objc-arc
to each as they are compiled. Add the flag to the files that need ARC disabled in the Compile Sources group under the target in the project navigator.
您可以通过在-fno-objc-arc
编译时将标志传递给每个文件来关闭每个文件的 ARC 。将标志添加到需要在项目导航器中目标下的编译源组中禁用 ARC 的文件。
Another option would be to compile ASIHttpRequest as its own framework that doesn't have ARC enabled and just link against the framework. Speak of, isn't ASIHttpRequest already in a framework? (I've not looked at it in a while)
另一种选择是将 ASIHttpRequest 编译为它自己的框架,该框架没有启用 ARC,只是链接到该框架。话说,ASIHttpRequest 不是已经在框架中了吗?(我有一段时间没看它了)
回答by sosborn
Keep using ARC, but disable it for the ASIHttpRequest files. This answer should point you in the right direction:
继续使用 ARC,但为 ASIHttpRequest 文件禁用它。这个答案应该指向正确的方向: