Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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? 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. After hours of trying to fix this, I renamed the file "libobjc.A.dylib" to "libobjc.dylib"and the error disappear. P/S: "libobjc.A.dylib" - located in /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer‌​/SDKs/*/usr/lib/, thanks again to Kevin.

like image 341
Kian Ping Avatar asked Nov 01 '13 04:11

Kian Ping


People also ask

How do I fix Xcode file not found?

I was facing this error after a merge from the repository (git). The final solution was: Delete the files from the xcode project navigator (only deleting references). Add them again to the project (dragging from finder into the project navigator).

How do I find my library in Xcode?

To open the library pane in newer versions of Xcode, select the square within a circle icon in the top right hand corner. This will bring up the library pane and you can search for any object. The keyboard shortcut to open this library pane is Shift + Cmd + L.


1 Answers

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.

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'.

To correct:

  • In Xcode, click on the target for your App.
  • 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'

flags

like image 163
Jasper Blues Avatar answered Sep 17 '22 02:09

Jasper Blues