在XCode中编译IOS应用程序时出现错误"找不到文件:-fobjc-arc"

mon*_*cht 7 xcode linker objective-c

添加OCMock框架后我得到了那个奇怪的错误...... :(

ld: file not found: -fobjc-arc
clang: error: linker command failed with exit code 1 (use -v to see invocation)

看起来编译器标志是否试图由XCode加载?

任何的想法?

最好的问候,hijolan

mak*_*dad 10

我在Xcode 4.3.2上得到了完全相同的错误.这是我的导航器日志; 我正在为Google juice添加它.

Ld /Users/makdad/Library/Developer/Xcode/DerivedData/Journal-bfkvfbsrkmrsjpddzfmwrstjfkzr/Build/Products/Debug-iphonesimulator/JournalTests.octest/JournalTests normal i386
cd /Users/makdad/Documents/MT/mt-mobile/iOS/Journal
setenv MACOSX_DEPLOYMENT_TARGET 10.6
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -bundle -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk -L/Users/phooze/Library/Developer/Xcode/DerivedData/Journal-bfkvfbsrkmrsjpddzfmwrstjfkzr/Build/Products/Debug-iphonesimulator -F/Users/phooze/Library/Developer/Xcode/DerivedData/Journal-bfkvfbsrkmrsjpddzfmwrstjfkzr/Build/Products/Debug-iphonesimulator -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/Developer/Library/Frameworks -F/Applications/Xcode.app/Contents/Developer/Library/Frameworks -filelist /Users/phooze/Library/Developer/Xcode/DerivedData/Journal-bfkvfbsrkmrsjpddzfmwrstjfkzr/Build/Intermediates/Journal.build/Debug-iphonesimulator/JournalTests.build/Objects-normal/i386/JournalTests.LinkFileList -mmacosx-version-min=10.6 -bundle_loader /Users/phooze/Library/Developer/Xcode/DerivedData/Journal-bfkvfbsrkmrsjpddzfmwrstjfkzr/Build/Products/Debug-iphonesimulator/Journal.app/Journal -Xlinker -objc_abi_version -Xlinker 2 -ObjC -force_load -fobjc-arc -ftest-coverage -Xlinker -no_implicit_dylibs -D__IPHONE_OS_VERSION_MIN_REQUIRED=40100 -lOCMock -framework Twitter -framework MapKit -framework MobileCoreServices -framework SystemConfiguration -lxml2 -licucore -framework CoreData -framework CoreGraphics -framework CFNetwork -framework QuartzCore -framework SenTestingKit -framework UIKit -framework Foundation -o /Users/phooze/Library/Developer/Xcode/DerivedData/Journal-bfkvfbsrkmrsjpddzfmwrstjfkzr/Build/Products/Debug-iphonesimulator/JournalTests.octest/JournalTests
Run Code Online (Sandbox Code Playgroud)

OCMock指令明确要求您添加链接器标志 - -ObjC-force_load.

-force_load期待一个值 - 请参阅此问题的答案,该问题解释了-all_load如果您不想指定库名称,那么该怎么办.

作为刚刚花了25分钟的人,我应该再次查看OCMock教程 - 我不认为这条教程非常清楚.

此博客文章有一个更好的图像,可以准确显示您的设置应该如何.

  • 需要注意的是,在Xcode 4.2及更高版本的LLVM中不再需要`-all_load`和`-force_load`:http://stackoverflow.com/a/7942924/19679.有一次,由于链接器错误,它们是必需的,但此问题已在最新版本的LLVM中得到解决.您应该能够删除"-ObjC"以外的链接器标志. (2认同)
  • @BradLarson感谢您的澄清.这就是它总是如此...人们添加巫毒魔法来解决一个错误,但是当错误修复后,没有人绕过"互联网"并清理旧的解决方法帖子的混乱. (2认同)