XCode/PhoneGap - Apple Mach-O Linker Error - objective-c

I just finished programming my application. I tried to archive the App for submission, but it didn't work, the following error was displayed. This problem only happens when I want to archive the app, running on Test device or Simulator works perfect (no errors).
Ld /Users/Admin/Library/Developer/Xcode/DerivedData/MyApp-ekptdmvfytpoeoaedgfvjzqudoqa/Build/Intermediates/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/MyApp.app/MyApp normal armv7
cd /Users/Admin/Desktop/MyApp3
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/Admin/Library/Developer/Xcode/DerivedData/MyApp-ekptdmvfytpoeoaedgfvjzqudoqa/Build/Intermediates/ArchiveIntermediates/MyApp/BuildProductsPath/Release-iphoneos -L/Users/Admin/Desktop/MyApp3 -F/Users/Admin/Library/Developer/Xcode/DerivedData/MyApp-ekptdmvfytpoeoaedgfvjzqudoqa/Build/Intermediates/ArchiveIntermediates/MyApp/BuildProductsPath/Release-iphoneos -filelist /Users/Admin/Library/Developer/Xcode/DerivedData/MyApp-ekptdmvfytpoeoaedgfvjzqudoqa/Build/Intermediates/ArchiveIntermediates/MyApp/IntermediateBuildFilesPath/MyApp.build/Release-iphoneos/MyApp.build/Objects-normal/armv7/MyApp.LinkFileList -dead_strip -weak_framework CoreFoundation -weak_framework UIKit -weak_framework AVFoundation -weak_framework CoreMedia -weak-lSystem -force_load /Users/Admin/Library/Developer/Xcode/DerivedData/MyApp-ekptdmvfytpoeoaedgfvjzqudoqa/Build/Intermediates/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/libCordova.a -ObjC -fobjc-link-runtime -miphoneos-version-min=6.1 -lxml2 -lxml2.2 -larchive.2 -framework CoreLocation -framework ImageIO -framework OpenAL -framework AssetsLibrary /Users/Admin/Library/Developer/Xcode/DerivedData/MyApp-ekptdmvfytpoeoaedgfvjzqudoqa/Build/Intermediates/ArchiveIntermediates/MyApp/BuildProductsPath/Release-iphoneos/libCordova.a -framework Foundation -weak_framework UIKit -framework CoreGraphics -framework AddressBook -framework AddressBookUI -framework AudioToolbox -weak_framework AVFoundation -framework CFNetwork -framework MediaPlayer -framework QuartzCore -framework SystemConfiguration -framework MobileCoreServices -weak_framework CoreMedia -framework CoreLocation -lCordova -o /Users/Admin/Library/Developer/Xcode/DerivedData/MyApp-ekptdmvfytpoeoaedgfvjzqudoqa/Build/Intermediates/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/MyApp.app/MyApp
ld: file not found: /Users/Admin/Library/Developer/Xcode/DerivedData/MyApp-ekptdmvfytpoeoaedgfvjzqudoqa/Build/Intermediates/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/libCordova.a
clang: error: linker command failed with exit code 1 (use -v to see invocation)
(null): File not found: /Users/Admin/Library/Developer/Xcode/DerivedData/Myapp-ekptdmvfytpoeoaedgfvjzqudoqa/Build/Intermediates/ArchiveIntermediates/Myapp/InstallationBuildProductsLocation/Applications/libCordova.a
(null): Linker command failed with exit code 1 (use -v to see invocation)
I already googled the ** out of this the past days. I tried everything I found. I set Build Active Architecture Only to "YES", deleted search paths (they were already empty), changed iOS Version, set Validate Build Product and other stuff.
I create my projects using terminal and ./create.
I even made a new clean project and posted my source code in there. The problem occures every time (even if I try to archive the new project without changing anything in source)
Using:
XCode 4.6.3
PhoneGap 2.9.0
I am desperate and hope for help. Thank you.

SOLUTION
I found a solution/work-around. (Couldn't post it because if 10Rep. limit, had to wait 8 hours)
In Target's Build Settings, find "Other Linker Flags"
Change $(TARGET_BUILD_DIR)/libCordova.a
To $(BUILT_PRODUCTS_DIR)/libCordova.a
Or just go to the Cordova site and download Cordova 3.0.0
(although the old known "splashscreen - white flash" is back)
With Cordova 3.0 this problem is fixed :)
Archiving works fine.

I am having the same issue... Works fine on simulator and test device, set Build Active Architecture to "YES" on both Cardova and MyApp projects, created using terminal ./create, rebuild the project from scratch.
Using: XCode 4.6.3 PhoneGap 2.9.0
Update:
Rebuilt my project with PhoneGap 3.0.0 and am now able to archive.

For me this was solved by setting "Build Active Architecture Only" to "Yes" for the "Release" setting in your Build Settings in xcode.
The fix described by FlyingLemon had already been done as I have the latest version of PhoneGap.
Phonegap version 3.4.0-0.19.13
Xcode version 5.1

Related

Linker command failed with exit code 1 after moving project from one computer to another

i am new to Xcode and obective-c and I have a problem with a project I have taken over from another developer on another machine. I cannot contact this programmer anymore (fired).
Ld /Users/*****/Library/Developer/Xcode/DerivedData/Dino-eyvcyvuofjuafncdadqeywyvdsra/Build/Products/Debug-iphonesimulator/Dino.app/Dino normal i386
cd /Users/******/Dropbox/Xcode/ABCiTY/Dino
setenv IPHONEOS_DEPLOYMENT_TARGET 5.1
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 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk -L/Users/******/Library/Developer/Xcode/DerivedData/Dino-eyvcyvuofjuafncdadqeywyvdsra/Build/Products/Debug-iphonesimulator -F/Users/******/Library/Developer/Xcode/DerivedData/Dino-eyvcyvuofjuafncdadqeywyvdsra/Build/Products/Debug-iphonesimulator -filelist /Users/******/Library/Developer/Xcode/DerivedData/Dino-eyvcyvuofjuafncdadqeywyvdsra/Build/Intermediates/Dino.build/Debug-iphonesimulator/Dino.build/Objects-normal/i386/Dino.LinkFileList -Xlinker -objc_abi_version -Xlinker 2 -ObjC -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=5.1 -lABCityCrossMarketing -framework AdSupport -framework CoreMotion -framework SystemConfiguration -framework CoreData -framework QuartzCore -framework CoreImage -framework AVFoundation -framework StoreKit -framework UIKit -framework Foundation -framework CoreGraphics -lGoogleAnalytics -lGoogleConversionTracking -o /Users/*******/Library/Developer/Xcode/DerivedData/Dino-eyvcyvuofjuafncdadqeywyvdsra/Build/Products/Debug-iphonesimulator/Dino.app/Dino
ld: library not found for -lABCityCrossMarketing
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Can anyone help me with this?
You are missing the library file libABCityCrossMarketing.a.
A google for "ABCityCrossMarketing" returns nothing for me. Looks bad. If you still have access to his machine, then that looks like the only way to recover this file (it's possible this library was written by him and never published).
The message is clear here, I think:
library not found for -lABCityCrossMarketing
This happens when you move folders and the controls or basically any file is misplaced by Xcode and it doesn't know where to find it. You'd have to add it to your project again or change the path to it wherever it was listed.

Application showing linker error for facebook SDK on device

My application is running fine on simulator without any errors. I am using facebook SDK in my application. When i try to run it on device, t\it shows me linker error. I went through some similar questions and tried their solutions like in the following links
tried this solution
and one more solution somewhere , saying unchecking Enable OpenMP Support worked for them but i can not find this option in my xcode4.5.
Ld "/Users/devusa/Library/Developer/Xcode/DerivedData/Virtual_Mirrorr-bsbznuqiwhaypbbjiftsqpwpmkdo/Build/Intermediates/Virtual Mirrorr.build/Debug-iphoneos/Virtual Mirror.build/Objects-normal/armv7s/Virtual Mirror" normal armv7s
cd "/Users/devusa/Documents/Start/Virtual Mirrorr"
setenv IPHONEOS_DEPLOYMENT_TARGET 4.3
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 armv7s -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk -L/Users/devusa/Library/Developer/Xcode/DerivedData/Virtual_Mirrorr-bsbznuqiwhaypbbjiftsqpwpmkdo/Build/Products/Debug-iphoneos -F/Users/devusa/Library/Developer/Xcode/DerivedData/Virtual_Mirrorr-bsbznuqiwhaypbbjiftsqpwpmkdo/Build/Products/Debug-iphoneos "-F/Users/devusa/Documents/Start/Virtual Mirrorr" -filelist "/Users/devusa/Library/Developer/Xcode/DerivedData/Virtual_Mirrorr-bsbznuqiwhaypbbjiftsqpwpmkdo/Build/Intermediates/Virtual Mirrorr.build/Debug-iphoneos/Virtual Mirror.build/Objects-normal/armv7s/Virtual Mirror.LinkFileList" -dead_strip -lsqlite3.0 -fobjc-arc -fobjc-link-runtime -miphoneos-version-min=4.3 -framework MessageUI -framework QuartzCore -framework SystemConfiguration -framework UIKit -framework Foundation -framework CoreGraphics -framework FacebookSDK -o "/Users/devusa/Library/Developer/Xcode/DerivedData/Virtual_Mirrorr-bsbznuqiwhaypbbjiftsqpwpmkdo/Build/Intermediates/Virtual Mirrorr.build/Debug-iphoneos/Virtual Mirror.build/Objects-normal/armv7s/Virtual Mirror"
ld: file is universal (3 slices) but does not contain a(n) armv7s slice: /Users/devusa/Documents/Start/Virtual Mirrorr/FacebookSDK.framework/FacebookSDK for architecture armv7s
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Three options:
Update to a newer version of the Facebook API
Add the armv7s architecture to the build settings of your Facebook framework
Remove the armv7s architecture from the build settings of your app
Basically, armv7s is the architecture used on the iPhone 5 and iPad 4. Your app supports it but the Facebook framework you're using does not.

Error linking Facebook library with MGTwitterEngine

I am trying to integrate Facebook into my app and have already implemented MGTwitterEngine with no issues. I keep getting an error now that I have tried to implement both Facebook sdk and MGTwitterEngine. I have read that there is a duplicate library between both SDK's and the individual said it had to do with the JSON Libraries. I deleted it from the Facebook sdk but I am still getting the error. Does anyone know what the issue may be?
So I understand it is referring to my armv6 in the error but there is no error at all until I try running Facebook sdk
Thanks
Ld "/Users/Alex/Library/Developer/Xcode/DerivedData/grocery-bhrkiajnjqfieahhdxilwtjggbqc/Build/Intermediates/grocery.build/Release-iphoneos/grocery.build/Objects-normal/armv6/grocery" normal armv6
cd /Users/Alex/Documents/Dictator/Lotto
setenv IPHONEOS_DEPLOYMENT_TARGET 3.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 armv6 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk -L/Users/Alex/Library/Developer/Xcode/DerivedData/grocery-bhrkiajnjqfieahhdxilwtjggbqc/Build/Products/Release-iphoneos "-L/Users/Alex/Documents/Dictator/Lotto/Classes/Twitter+OAuth 2/SAOAuthTwitterEngine" -F/Users/Alex/Library/Developer/Xcode/DerivedData/grocery-bhrkiajnjqfieahhdxilwtjggbqc/Build/Products/Release-iphoneos -filelist "/Users/Alex/Library/Developer/Xcode/DerivedData/grocery-bhrkiajnjqfieahhdxilwtjggbqc/Build/Intermediates/grocery.build/Release-iphoneos/grocery.build/Objects-normal/armv6/grocery.LinkFileList" -dead_strip -miphoneos-version-min=3.1 -framework Security -lxml2 -framework MessageUI -framework Foundation -framework UIKit -framework CoreGraphics -framework CoreData -framework MapKit -framework SystemConfiguration -lOAuth -o "/Users/Alex/Library/Developer/Xcode/DerivedData/grocery-bhrkiajnjqfieahhdxilwtjggbqc/Build/Intermediates/grocery.build/Release-iphoneos/Lotto Fetcher.build/Objects-normal/armv6/grocery"
ld: duplicate symbol _main in /Users/Alex/Library/Developer/Xcode/DerivedData/grocery-bhrkiajnjqfieahhdxilwtjggbqc/Build/Intermediates/grocery.build/Release-iphoneos/Lotto Fetcher.build/Objects-normal/armv6/main-280587BD193E8878.o and /Users/Alex/Library/Developer/Xcode/DerivedData/grocery-bhrkiajnjqfieahhdxilwtjggbqc/Build/Intermediates/grocery.build/Release-iphoneos/Lotto Fetcher.build/Objects-normal/armv6/main-B9843B6026D6EFA4.o for architecture armv6
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Duplicate symbol
Search your project for two copies of main.m file. :-)

ld: library not found for -lz

This is driving me crazy, when i try to compile on the simulator, everything is ok, but on the device i got this error:
ld: library not found for -lz
Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang failed with exit code 1
Please help me understand the source of the problem:
Ld /Users/ZConsulting/Library/Developer/Xcode/DerivedData/Fontenay-sous-Bois-dhlecgdgtoldsadoctkyueriyius/Build/Products/Debug-iphoneos/Fontenay-sous-Bois.app/Fontenay-sous-Bois normal armv7
cd /Users/ZConsulting/Desktop/Fontenay-sous-Bois
setenv IPHONEOS_DEPLOYMENT_TARGET 5.0
setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang -arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk -L/Users/ZConsulting/Library/Developer/Xcode/DerivedData/Fontenay-sous-Bois-dhlecgdgtoldsadoctkyueriyius/Build/Products
/Debug-iphoneos -F/Users/ZConsulting/Library/Developer/Xcode/DerivedData/Fontenay-sous-Bois-dhlecgdgtoldsadoctkyueriyius/Build/Products/Debug-iphoneos -F/Developer/Platforms/iPhoneOS.platform/Developer/SDKs
/iPhoneOS5.0.sdk/Developer/Library/Frameworks -filelist /Users/ZConsulting/Library/Developer/Xcode/DerivedData/Fontenay-sous-Bois-dhlecgdgtoldsadoctkyueriyius/Build/Intermediates/Fontenay-sous-Bois.build/Debug-iphoneos/Fontenay-sous-Bois.build/Objects-normal/armv7/Fontenay-sous-Bois.LinkFileList -dead_strip -fobjc-arc -miphoneos-version-min=5.0 -framework SenTestingKit -lz -lz.1.1.3 -framework MobileCoreServices
-framework SystemConfiguration -framework CFNetwork -framework CoreLocation -framework MapKit -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/ZConsulting/Library/Developer/Xcode/DerivedData/Fontenay-sous-Bois-dhlecgdgtoldsadoctkyueriyius/Build/Products/Debug-iphoneos/Fontenay-sous-Bois.app/Fontenay-sous-Bois
EDIT:
I did import the libz.1.1.3.dylib framework:
The only libz that i got in the Linked frameworks is the libz.1.1.3.dylib
You did specify the library libz.dylib in the Linked frameworks and Libraries item rather than the direct reference to libz.1.1.3 - in general you should use the most generic version of a library for compilation rather than a more specific one
Secondly, make sure that the libz.dylib is present under the iOS SDK - if it's missing, then it may be a mis-installed SDK (reinstall should fix that).
i.e.
find /Developer/Platforms -name libz.dylib
should result in a non-empty output for a libz.dylib under iPhoneOS5.0.sdk
Also see the answer to iPhone - Linker Error in Xcode 4.2 Preview, which is a similar issue to this.
i got the same error with a different library:
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
to resolve this, under search paths -> user header search paths -> release i put:
"$(BUILD_ROOT)/../IntermediateBuildFilesPath/UninstalledProducts/include"
keep in mind that I get this bug only when I archive, and my archive is a based off my release scheme..
update:
I got the same problem (on a different occasion/project) for the lpods Library (ie cocoapods).. the way i figured out to solve this is by realizing that the build worked fine on my development scheme but not my debug scheme. basically the development scheme had no for build active architectures only whereas debug had yes. I simply changed debug to no in all the targets under cocoapods

Apple mach-o linker flag error

I am trying to add TapJoy in my app, after adding the TapJoy class I got this error:
Ld /Users/tamannarahman/Library/Developer/Xcode/DerivedData/Tapjoy-fkglfvxrrgqjzvgmabanjaqvquov/Build/Intermediates/Tapjoy.build/Debug-iphoneos/Tapjoy.build/Objects-normal/armv6/Tapjoy normal armv6
cd /Tamanna/Tapjoy
setenv IPHONEOS_DEPLOYMENT_TARGET 3.0
setenv PATH "/Xcode 4/Platforms/iPhoneOS.platform/Developer/usr/bin:/Xcode 4/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
"/Xcode 4/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc-4.2" -arch armv6 -isysroot "/Xcode 4/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk" -L/Users/tamannarahman/Library/Developer/Xcode/DerivedData/Tapjoy-fkglfvxrrgqjzvgmabanjaqvquov/Build/Products/Debug-iphoneos -F/Users/tamannarahman/Library/Developer/Xcode/DerivedData/Tapjoy-fkglfvxrrgqjzvgmabanjaqvquov/Build/Products/Debug-iphoneos -filelist /Users/tamannarahman/Library/Developer/Xcode/DerivedData/Tapjoy-fkglfvxrrgqjzvgmabanjaqvquov/Build/Intermediates/Tapjoy.build/Debug-iphoneos/Tapjoy.build/Objects-normal/armv6/Tapjoy.LinkFileList -dead_strip libxml2 -miphoneos-version-min=3.0 -framework CoreTelephony -framework QuartzCore -framework OpenGLES -framework OpenAL -framework AudioToolbox -framework AVFoundation -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/tamannarahman/Library/Developer/Xcode/DerivedData/Tapjoy-fkglfvxrrgqjzvgmabanjaqvquov/Build/Intermediates/Tapjoy.build/Debug-iphoneos/Tapjoy.build/Objects-normal/armv6/Tapjoy
arm-apple-darwin10-llvm-gcc-4.2: libxml2: No such file or directory
Command /Xcode 4/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc-4.2 failed with exit code 1
Can anyone help ?
The relevant part of that log is:
libxml2: No such file or directory
You will want to add the libxml2 library to your project's "Link Binary with Libraries" Build Phase. I believe it's named libxml2.dylib, there may be multiple versions differing in version number.
If the library is already added, remove it and re-add it. It may be linked to the wrong Xcode installation, or the particular version may have been removed or renamed in the latest Xcode.