我在我的项目中成功地使用了ARC.然而,我遇到了一些文件(例如,在单元测试和模拟对象中),其中的ARC规则现在有点脆弱.我记得听说有一种方法可以在每个文件的基础上禁用ARC,尽管我一直找不到这个选项.
这可能吗?如何基于每个文件禁用ARC?
我在我的项目中成功地使用了ARC.然而,我遇到了一些文件(例如,在单元测试和模拟对象中),其中的ARC规则现在有点脆弱.我记得听说有一种方法可以在每个文件的基础上禁用ARC,尽管我一直找不到这个选项.
这可能吗?如何基于每个文件禁用ARC?
通过为单个文件添加-fno-objc-arc
编译器标志,可以禁用这些文件的ARC.
You add compiler flags in Targets -> Build Phases -> Compile Sources. You have to double click on the right column of the row under Compiler Flags. You can also add it to multiple files by holding the cmd button to select the files and then pressing enter to bring up the flag edit box. (Note that editing multiple files will overwrite any flags that it may already have.)
我创建了一个示例项目:https://github.com/jaminguy/NoArc
有关更多信息,请参见此答案: