Objective-C ARC and Legacy Runtime compiling error

2020-03-18 19:32发布

问题:

I'm trying to compile sources with Xcode 4.6, for 32bit architecture, but getting this error:

error: -fobjc-arc is not supported on platforms using the legacy runtime
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1

What's wrong?

回答1:

You're mixing ARC (automatic reference counting) with the older Objective-C 1.0 runtime, which does not support ARC.

32-bit apps on OSX, automatically use the 1.0 Runtime, so you'll have to disable ARC for your project, and use Manual Reference Counting.



回答2:

This problem recently resurfaced because Xcode 5 removes the ARCHS parameter - if you let it. But if you have a build server with Xcode 4 this defaults there to building 32 and 64 bit, which fails if you have ARC enabled.

See my writeup for a more detailed explanation.