简体   繁体   English

找不到-lobjc的xcode库

[英]xcode library not found for -lobjc

I am getting this error when I am trying to run it on my device, however it working fine when I run it on simulator. 当我试图在我的设备上运行它时,我收到此错误,但是当我在模拟器上运行它时它工作正常。 Is this a tool chain error or SDK header error? 这是工具链错误还是SDK标头错误? Below is the error message I obtain when compiling. 以下是我在编译时获得的错误消息。

Error Message: 错误信息:

Ld /Users/KhangYu/Library/Developer/Xcode/DerivedData/mobiletimetec-bbuzqjqgmijmomgdmvebkbyasqii/Build/Intermediates/mobiletimetec.build/Debug-iphoneos/mobiletimetec.build/Objects-normal/armv7/mobiletimetec normal armv7
    cd /Users/KhangYu/Desktop/KPTesting/setting
    setenv IPHONEOS_DEPLOYMENT_TARGET 6.1
    setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.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 armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk -L/Users/KhangYu/Library/Developer/Xcode/DerivedData/mobiletimetec-bbuzqjqgmijmomgdmvebkbyasqii/Build/Products/Debug-iphoneos -L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/usr/lib/system -F/Users/KhangYu/Library/Developer/Xcode/DerivedData/mobiletimetec-bbuzqjqgmijmomgdmvebkbyasqii/Build/Products/Debug-iphoneos -F/Applications/Xcode.app/Contents/Developer/Library/Frameworks -filelist /Users/KhangYu/Library/Developer/Xcode/DerivedData/mobiletimetec-bbuzqjqgmijmomgdmvebkbyasqii/Build/Intermediates/mobiletimetec.build/Debug-iphoneos/mobiletimetec.build/Objects-normal/armv7/mobiletimetec.LinkFileList -dead_strip -fobjc-arc -fobjc-link-runtime -miphoneos-version-min=6.1 -framework SystemConfiguration -framework AVFoundation -lsqlite3.0 -framework MapKit -framework CoreLocation -framework MessageUI -framework QuartzCore -framework Security -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/KhangYu/Library/Developer/Xcode/DerivedData/mobiletimetec-bbuzqjqgmijmomgdmvebkbyasqii/Build/Intermediates/mobiletimetec.build/Debug-iphoneos/mobiletimetec.build/Objects-normal/armv7/mobiletimetec

ld: library not found for -lobjc
clang: error: linker command failed with exit code 1 (use -v to see invocation)

//-- END -- // - 结束 -

This is going to be the death of me. 这将是我的死亡。 Any idea on how to solve it? 关于如何解决它的任何想法? Your help will be greatly appreciated. 对你的帮助表示感谢。

Thanks in advance. 提前致谢。

Solution

Thanks Kevin and Jasper Blues reply and also thanks Reno Jones to edit my post. 感谢Kevin和Jasper Blues的回复,也感谢Reno Jones编辑我的帖子。 After hours of trying to fix this, I renamed the file "libobjc.A.dylib" to "libobjc.dylib"and the error disappear. 在尝试修复此问题数小时后,我将文件“libobjc.A.dylib”重命名为“libobjc.dylib”,错误消失。 P/S: "libobjc.A.dylib" - located in /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer‌​/SDKs/*/usr/lib/, thanks again to Kevin. P / S:“libobjc.A.dylib” - 位于/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer / SDKs / * / usr / lib /,再次感谢Kevin。

My guess is that it works on the Simulator, but not the device because you've specified separate 'OTHER LINKER FLAGS' for both 'Debug' and 'Release' configurations. 我的猜测是它可以在模拟器上运行,但不适用于设备,因为你已经为“调试”和“释放”配置指定了单独的“其他链接标记”。 You'd usually do this if you're linking in a debug framework such as 'Reveal', 'DCIntrospect', etc. 如果您在调试框架中链接,例如'Reveal','DCIntrospect'等,通常会这样做。

The one for 'Release' looks to be incorrect. '发布'看起来不正确。 It should be '-Objc' and not '-lObjc' - we're telling the compiler that we're using Objective-C itself, and not to load a library called 'Objc'. 它应该是'-Objc'而不是'-lObjc' - 我们告诉编译器我们正在使用Objective-C本身,而不是加载一个名为'Objc'的库。

To correct: 纠正:

  • In Xcode, click on the target for your App. 在Xcode中,单击应用程序的目标。
  • Open the 'Build Settings' tab. 打开“构建设置”选项卡。
  • Search for 'Other linker flags' - so you're not overwhelmed by options. 搜索“其他链接器标志” - 这样您就不会被选项所淹没。
  • Correct the 'Release' config. 更正'发布'配置。 Change '-lObjc' to '-Objc' 将'-lObjc'更改为'-Objc'

旗

无需重命名“libobjc.A.dylib”,只需将其重新链接为:ln -s ./libobjc.A.dylib ./libobjc.dylib

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM