xcode ARC:将编译器标志设置为 -fno-objc-arc 并生成错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9498644/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 23:28:49  来源:igfitidea点击:

ARC: Setting compiler flags to -fno-objc-arc and build errors

iosxcodebuildcompiler-errorsautomatic-ref-counting

提问by Lorenzo B

Following a stackoverflow topic about disabling ARC compiler mechanism for specific classes, I added the -fno-objc-arcargument to Compiler Flags column under Compile Sources section (Buil Phases tab within TARGETS project). Even if settings have been validated, I'm not able to build my application since the compiler says that retain, release, etc.cannot be used under ARC.

遵循有关禁用特定类的 ARC 编译器机制的 stackoverflow 主题,我将-fno-objc-arc参数添加到编译源部分(目标项目中的构建阶段选项卡)下的编译器标志列。即使设置已经过验证,我也无法构建我的应用程序,因为编译器说retain, release, etc.不能在 ARC 下使用。

How can I fix the above problem? Thank you in advance.

我该如何解决上述问题?先感谢您。

回答by Mugunth

Did you use the migration tool to perform your migration? Did you add the compiler flags to allthe files that has release/retain?

您是否使用迁移工具执行迁移?您是否将编译器标志添加到所有具有发布/保留功能的文件中?

I wrote about ARC migration on my bloghere.

在我的博客上写了关于ARC 迁移的文章

回答by Kamar Shad

Yes Thats true if you are using the ARC For iphone Application. You can not use manually retain, release, etc..these messages automatically placed by the complier. You should check your code properly that for which classes you get error. I think so,you are still using retain, release, etc.for ARC enabled Classes. So Firstly check your classes,in which that error Occurred.

是的,如果您使用的是 ARC For iphone 应用程序,那就对了。您不能手动使用。retain, release, etc.这些消息由编译器自动放置。您应该正确检查您的代码,了解您收到错误的类。我认为是这样,您仍在使用retain, release, etc.启用 ARC 的类。因此,首先检查您的课程,其中发生了该错误。