xcode library not found for -lobjc - ios

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.

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'

There is no need to rename "libobjc.A.dylib", just re-link it like : ln -s ./libobjc.A.dylib ./libobjc.dylib

Related

Apple Mach-O-Linker Error CocoaPods

I've been trying to get my app up and running. From what I could tell the app was missing Cocoapods as a dependency. So. I installed and added Cocoapods. But I'm still getting the same error for whatever reason. I'm an inexperienced developer trying to teach himself I must add.
Ld
/Users/bfarag/Library/Developer/Xcode/DerivedData/Umbrella-cspuzusfqmqgnwdqfhtiyivaqwke/Build/Products/Debug-iphonesimulator/Umbrella.app/Umbrella
normal i386
cd "/Users/bfarag/Desktop/The Nerdery/BRAVO.iOS.CodeChallenge"
export IPHONEOS_DEPLOYMENT_TARGET=7.0
export 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 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk
-L/Users/bfarag/Library/Developer/Xcode/DerivedData/Umbrella-cspuzusfqmqgnwdqfhtiyivaqwke/Build/Products/Debug-iphonesimulator
-F/Users/bfarag/Library/Developer/Xcode/DerivedData/Umbrella-cspuzusfqmqgnwdqfhtiyivaqwke/Build/Products/Debug-iphonesimulator
-filelist /Users/bfarag/Library/Developer/Xcode/DerivedData/Umbrella-cspuzusfqmqgnwdqfhtiyivaqwke/Build/Intermediates/Umbrella.build/Debug-iphonesimulator/Umbrella.build/Objects-normal/i386/Umbrella.LinkFileList
-Xlinker -objc_abi_version -Xlinker 2 -ObjC -lPods-Umbrella-AFNetworking -framework CoreGraphics -framework MobileCoreServices -framework Security -framework SystemConfiguration
-fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=7.0 -framework Accelerate -framework UIKit -framework Foundation -framework CoreGraphics -lPods -lPods-Umbrella -Xlinker -dependency_info -Xlinker /Users/bfarag/Library/Developer/Xcode/DerivedData/Umbrella-cspuzusfqmqgnwdqfhtiyivaqwke/Build/Intermediates/Umbrella.build/Debug-iphonesimulator/Umbrella.build/Objects-normal/i386/Umbrella_dependency_info.dat
-o /Users/bfarag/Library/Developer/Xcode/DerivedData/Umbrella-cspuzusfqmqgnwdqfhtiyivaqwke/Build/Products/Debug-iphonesimulator/Umbrella.app/Umbrella
ld: library not found for -lPods
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This error usually occurs either when you don't have the correct frameworks (might be missing one) or when you don't have the right thing in linker flags.
Go to the main page for the app (on the navigation thing on the left click on your apps name or the top section) -> Build Settings and under Linker Flags, make sure there is nothing in your Other Linker Flags. I had this same error when I had -ObjC in my other Linker Flags.
You might also want to try adding -lPods to your Other Linker Flags or adding the CoreGraphics framework if you don't already have it.
Good luck
Open workspace file, not project file. Cocoapods automatically creates a xcworkspace file on the same directory as xcproject file.
Xcode started displaying this message and I tried pretty much everything to solve it. What finally did the trick for me was deleting all content from ~/Library/Developer/Xcode/DerivedData/

(Cordova) Xcode 5.1 Error Apple Mach-O Linker error libCordova.a file not found

I recently tried to archive my product in order to submit it to the app store, but came across this error that has eaten up my time. The error goes as follows:
Ld
/Users/guled/Library/Developer/Xcode/DerivedData/Alter-arpezfgnfzcguefnjpllgwzddkld/Build/Intermediates/ArchiveIntermediates/Alter-App\
Store/IntermediateBuildFilesPath/Alter.build/App\
Store-iphoneos/Alter.build/Objects-normal/armv7/Alter normal armv7
cd /Applications/MAMP/htdocs/Alter/platforms/ios
export IPHONEOS_DEPLOYMENT_TARGET=6.0
export 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/iPhoneOS7.1.sdk
-L/Users/guled/Library/Developer/Xcode/DerivedData/Alter-arpezfgnfzcguefnjpllgwzddkld/Build/Intermediates/ArchiveIntermediates/Alter-App\
Store/BuildProductsPath/App\ Store-iphoneos
-F/Users/guled/Library/Developer/Xcode/DerivedData/Alter-arpezfgnfzcguefnjpllgwzddkld/Build/Intermediates/ArchiveIntermediates/Alter-App\
Store/BuildProductsPath/App\ Store-iphoneos -filelist
/Users/guled/Library/Developer/Xcode/DerivedData/Alter-arpezfgnfzcguefnjpllgwzddkld/Build/Intermediates/ArchiveIntermediates/Alter-App\
Store/IntermediateBuildFilesPath/Alter.build/App\
Store-iphoneos/Alter.build/Objects-normal/armv7/Alter.LinkFileList
-dead_strip -weak_framework CoreFoundation -weak_framework UIKit -weak_framework AVFoundation -weak_framework CoreMedia -weak-lSystem -force_load /Users/guled/Library/Developer/Xcode/DerivedData/Alter-arpezfgnfzcguefnjpllgwzddkld/Build/Intermediates/ArchiveIntermediates/Alter-App\
Store/BuildProductsPath/App\ Store-iphoneos/libCordova.a -ObjC
-fobjc-arc -fobjc-link-runtime -miphoneos-version-min=6.0 -framework AssetsLibrary
/Users/guled/Library/Developer/Xcode/DerivedData/Alter-arpezfgnfzcguefnjpllgwzddkld/Build/Intermediates/ArchiveIntermediates/Alter-App\
Store/BuildProductsPath/Release-iphoneos/libCordova.a -framework
CoreGraphics -framework MobileCoreServices -framework CoreLocation
-Xlinker -dependency_info -Xlinker /Users/guled/Library/Developer/Xcode/DerivedData/Alter-arpezfgnfzcguefnjpllgwzddkld/Build/Intermediates/ArchiveIntermediates/Alter-App\
Store/IntermediateBuildFilesPath/Alter.build/App\
Store-iphoneos/Alter.build/Objects-normal/armv7/Alter_dependency_info.dat
-o /Users/guled/Library/Developer/Xcode/DerivedData/Alter-arpezfgnfzcguefnjpllgwzddkld/Build/Intermediates/ArchiveIntermediates/Alter-App\
Store/IntermediateBuildFilesPath/Alter.build/App\
Store-iphoneos/Alter.build/Objects-normal/armv7/Alter
This error also follows:
ld: file not found:
/Users/guled/Library/Developer/Xcode/DerivedData/Alter-arpezfgnfzcguefnjpllgwzddkld/Build/Intermediates/ArchiveIntermediates/Alter-App
Store/BuildProductsPath/App Store-iphoneos/libCordova.a clang: error:
linker command failed with exit code 1 (use -v to see invocation)
Can someone help me?
This issue was driving me crazy for hours. Apps builds and runs fine. Cannot create archive. Cordova 3.5 and Xcode 5.1.1.
I was able to resolve this issue by using the solution in the comments from Somnibyte. I was creating a "Distribution" build configuration (like I always do), and I was unable to create an archive from this "Distribution" configuration. Spent hours tinkering and trying. I finally found the comment from Somnibyte, attempted to simply archive the "Release" build configuration instead, and... BAM! It worked! Thank you thank you thank you Somnibyte. Hope this saves someone else some time.
I think the issue may be here:
Have you tried manually adding the libcordova.a file to the xcode project? Thats all I can think of, having no experience with cordova myself.
The error here seems to be that xcode is just failing to find the libcordova.a, so this link may help some.
https://developer.apple.com/library/ios/recipes/xcode_help-project_editor/Articles/AddingaLibrarytoaTarget.html

missing required architecture armv7 in file XCTest on building application target

To start, i looked at all the other search topics and none applied or didn't work. For example, i have a hard time that apple didn't make xctest compatible with all architectures.
On a Xcode project for work i randomly started getting the following build error on linking:
Ld /Users/eallen/Library/Developer/Xcode/DerivedData/InVenueExperience-fgszkxctprmkuvbvwzgprcuveheo/Build/Intermediates/InVenueExperience.build/Debug-iphoneos/InVenueExperience.build/Objects-normal/armv7/InVenueExperience normal armv7
cd /Users/eallen/tmdev/ios/mive
setenv IPHONEOS_DEPLOYMENT_TARGET 7.0
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/iPhoneOS7.0.sdk -L/Users/eallen/Library/Developer/Xcode/DerivedData/InVenueExperience-fgszkxctprmkuvbvwzgprcuveheo/Build/Products/Debug-iphoneos -L/Users/eallen/tmdev/ios/mive -L/Users/eallen/Library/Developer/Xcode/DerivedData/InVenueExperience-fgszkxctprmkuvbvwzgprcuveheo/Build/Intermediates -F/Users/eallen/Library/Developer/Xcode/DerivedData/InVenueExperience-fgszkxctprmkuvbvwzgprcuveheo/Build/Products/Debug-iphoneos -FFrameworks -FPods/Pixate/Framework/iOS -F/Applications/Xcode.app/Contents/Developer/Library/Frameworks -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/Developer/Library/Frameworks -filelist /Users/eallen/Library/Developer/Xcode/DerivedData/InVenueExperience-fgszkxctprmkuvbvwzgprcuveheo/Build/Intermediates/InVenueExperience.build/Debug-iphoneos/InVenueExperience.build/Objects-normal/armv7/InVenueExperience.LinkFileList -dead_strip -ObjC -lObjC -lxml2 -framework CoreGraphics -framework CoreText -framework MobileCoreServices -framework Pixate -framework QuartzCore -framework Security -framework SystemConfiguration -framework UIKit -fobjc-arc -fobjc-link-runtime -fprofile-arcs -ftest-coverage -miphoneos-version-min=7.0 -lPods -framework QuartzCore -framework CoreText -framework CoreGraphics -framework CoreData -framework UIKit -framework Foundation -framework Crashlytics -Xlinker -dependency_info -Xlinker /Users/eallen/Library/Developer/Xcode/DerivedData/InVenueExperience-fgszkxctprmkuvbvwzgprcuveheo/Build/Intermediates/InVenueExperience.build/Debug-iphoneos/InVenueExperience.build/Objects-normal/armv7/InVenueExperience_dependency_info.dat -o /Users/eallen/Library/Developer/Xcode/DerivedData/InVenueExperience-fgszkxctprmkuvbvwzgprcuveheo/Build/Intermediates/InVenueExperience.build/Debug-iphoneos/InVenueExperience.build/Objects-normal/armv7/InVenueExperience
ld: in '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/XCTest.framework/XCTest', missing required architecture armv7 in file /Applications/Xcode.app/Contents/Developer/Library/Frameworks/XCTest.framework/XCTest (2 slices) for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
All this while trying to build my application target and NOT my test target. Some further notes:
I am NOT linking against XCTest in my build settings for the application target
I am building, not testing this specific target
I do have in both my build settings -> Architectures|Valid Architectures "Standard Architectures (armv7, armv7s).
This only happens when i build for a iOS device and not a simulator...i think this is because building for a simulator only tries the i386 architecture?
To be honest, i have no idea why the linker is even trying to link against XCTest in this case...i even modified the scheme to remove all tests though i wasn't trying to test against the target.
Please feel free to ask me any other questions.
You may have the same simple but frustrating problem as I had. It's a scheme setting:
Click on your project scheme in the toolbar (right of the play/stop buttons), and select 'Edit' from the popup. Under the 'Build' item on the left, make sure your test targets only have 'Test' checked.
Please make sure the Build Setting of "build Active Architecture only" is set to NO, maybe it's the cause of this problem.
Turns out that buried deep in the compile sources for the application target i had a file that included imports for XCTest stuff...removing this immediately made this go away.
So answer being verify that you do not have anything in your compile sources list that may reference a library you didn't intend
I just had the same issue after including a third-party project. When selecting the target I chose the main project target (not the test target), but the included project had a sub-target which were unit tests. Xcode helpfully added those to my main application target. After changing the target setting for the relevant file it worked alright.
It happens that after adding $(PLATFORM_DIR)/Developer/Library/Frameworks as a first item in <Target>/<Build Settings>/<Search Paths>/<Framework Search Paths> I got rid of nasty "ld: framework not found XCTest for architecture arm64" link error by using XCode 6.3.1.

RestKit Linker error

I have been following the RestKit installation instructions but I now have an error when I try to build the app. This is for ios, iPad specific.
I get "Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang failed with exit code 1"
Description:
Ld build/Debug-iphonesimulator/iDoor.app/iDoor normal i386
cd "/Users/User/Dropbox/darxstudios/FatCow Games/iDoor"
setenv MACOSX_DEPLOYMENT_TARGET 10.6
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang -arch i386 -
isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk "-L/Users/User/Dropbox/darxstudios/FatCow Games/iDoor/build/Debug-iphonesimulator" "-F/Users/User/Dropbox/darxstudios/FatCow Games/iDoor/build/Debug-iphonesimulator" -filelist "/Users/User/Dropbox/darxstudios/FatCow Games/iDoor/build/iDoor.build/Debug-iphonesimulator/iDoor.build/Objects-normal/i386/iDoor.LinkFileList" -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -ObjC - all_load -fobjc-arc -Xlinker -no_implicit_dylibs -D__IPHONE_OS_VERSION_MIN_REQUIRED=50000 -framework Security -lxml2 -framework SystemConfiguration -framework MobileCoreServices -framework CoreData -framework CFNetwork -framework UIKit -framework Foundation -framework CoreGraphics -o "/Users/User/Dropbox/darxstudios/FatCow Games/iDoor/build/Debug-iphonesimulator/iDoor.app/iDoor"
I am not an expert of using XCode but it almost appears that it wants to deploy as MAC OSX but I have the targets setup for ios. Any help would be appreciated.
Also I do not have RestKit.framework added (the mac osx version) and i was following the instructions for installing RestKit here: https://github.com/RestKit/RestKit/wiki/Installing-RestKit-in-Xcode-4.x
After looking further i notice that in the "Link Binary With Libraries" the libRestKit.a is red. I am thinking that may be a part or the whole issue...
So I found the answer, I can't believe I missed this very simple thing. Hopefully this will help anyone else who has this issue.
In the Linker section ensure that it is "Other Linker Flags" -ObjC -all_load
I mistakenly entered -ObjC - all_load
The space after the second dash was the cause.
I forgot to include libRestKit.a and receive the same error. Adding the image to help others like me.

Apple Mach-O Linker (id) Error

I have an error below:
ld /Volumes/Data/Library/Developer/Xcode/DerivedData/uniText-cgynaitlevdrajfeoaldwldehaft/Build/Products/Debug-iphonesimulator/uniText.app/uniText normal i386
cd "/Volumes/Data/Documents/XCode Projects/Trans SMS"
setenv MACOSX_DEPLOYMENT_TARGET 10.6
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk -L/Volumes/Data/Library/Developer/Xcode/DerivedData/uniText-cgynaitlevdrajfeoaldwldehaft/Build/Products/Debug-iphonesimulator -F/Volumes/Data/Library/Developer/Xcode/DerivedData/uniText-cgynaitlevdrajfeoaldwldehaft/Build/Products/Debug-iphonesimulator -filelist /Volumes/Data/Library/Developer/Xcode/DerivedData/uniText-cgynaitlevdrajfeoaldwldehaft/Build/Intermediates/uniText.build/Debug-iphonesimulator/uniText.build/Objects-normal/i386/uniText.LinkFileList -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -framework SystemConfiguration -framework MessageUI -framework AddressBook -framework AddressBookUI -framework CoreTelephony -lsqlite3.0 -framework UIKit -framework Foundation -framework CoreGraphics -o /Volumes/Data/Library/Developer/Xcode/DerivedData/uniText-cgynaitlevdrajfeoaldwldehaft/Build/Products/Debug-iphonesimulator/uniText.app/uniText
ld: duplicate symbol _OBJC_IVAR_$_FMDatabase.databasePath in /Volumes/Data/Library/Developer/Xcode/DerivedData/uniText-cgynaitlevdrajfeoaldwldehaft/Build/Intermediates/uniText.build/Debug-iphonesimulator/uniText.build/Objects-normal/i386/FMDatabase-566DC6D59187887D.o and /Volumes/Data/Library/Developer/Xcode/DerivedData/uniText-cgynaitlevdrajfeoaldwldehaft/Build/Intermediates/uniText.build/Debug-iphonesimulator/uniText.build/Objects-normal/i386/FMDatabase-566DC6D59187887D.o for architecture i386
collect2: ld returned 1 exit status
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2 failed with exit code 1
Could someone help me out?
It used to work properly before.
I have no idea what I have changed in the project sources.
But I am sure that I never changed anything in that FMDatabase.h and .m.
The relevant portion of your error is ld: duplicate symbol _OBJC_IVAR_$_FMDatabase.databasePath. For some reason, the linker (ld) is trying to link FMDatabase twice. Check to see if you have multiple copies of it in your project.
I once got this error when I was initializing values to constants defined in the global scope in my .h file.
Solved the problem, by declaring them in the header, and initializing them in the .m file.
This is a quite old post, but maybe it still helps somebody.
Just had the same problem, for me the solution was: I accidently linked an .m file in one of the headers instead of the .h file. Just changed that to properly link the .h file.
Check if you import framework which required.
I solve the problem by updating my framework.
I solved by performing a Clean .
Then could Build.

Resources