-fno-objc-arc not working to disable ARC

非 Y 不嫁゛ 提交于 2019-12-05 01:42:00

Weird thing. I tried adding the -fno-objc-arc flag to some Facebook files and the project finally built. I guess the lesson here is that when Xcode generates these types of errors, the source of the problem may be in another file. This may especially be true if Xcode is complaining about a file that you have already flagged!

Hopefully this will be of help to somebody :).

Just a little additional hint:

If you have multiple targets in your project check if you added the compiler flag -fno-objc-arc to all of them.

"Convert to Objective-C ARC" is a code rewriting tool, -fno-objc-arc on the other hand is a compile time flag. It's simply irrelevant for the purpose of refactoring.

Before you click "Check", expend the target and deselect the files you want to keep ARC-free.

DarkestOne

Actually the problem is simple. Make sure there is no carriage return after the -fno-objc-arc flag you have entered in the compiler flags dialog.

I managed to get into this state by a .m file that #imported a .m file that was not ARC compliant. The compiler complains about the included file, which may well be tagged -fno-objc-arc. I had to flag the .m that was doing the including.

I discovered this by expanding the build output on the failing and looking at the raw log which showed the file that was failing to compile (different from the one in the warning).

I also needed to delete the derived data file.

Had the same issue but was unable to find the offending file (as in Brotto's solution). So simply wrapped the non-arc complaint code snippets in the following #if statement block:

#if !(__has_feature(objc_arc))

//...non-arc code

#endif

I was able to fix my issues by unchecking the non-ARC files in the Refactor -> Convert to Objective-C ARC modal. Even though the files were already being disincluded due to the 'fno-objc-arc' flag. Once I unchecked the files, Xcode started spitting out better errors that allowed me to find files that needed some fixing. After making those changes, I was good to go.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!