How do I fix an Apple Mach-O Link Error - ios

I am trying to archive my IOS project in Xcode 5 for distribution and I get an error which says "Apple Mach-O Link Error and:
Undefined symbols
for architecture arm64: "_OBJC_METACLASS_$_CDVCommandDelegateImpl",
referenced from: _OBJC_METACLASS_$_MainCommandDelegate in MainViewController.o "_CDVLocalNotification",
referenced from: -[AppDelegate application: didReceiveLocalNotification: ] in AppDelegate.o "_OBJC_CLASS_$_CDVCommandDelegateImpl",
referenced from: _OBJC_CLASS_$_MainCommandDelegate in MainViewController.o "_OBJC_CLASS_$_CDVCommandQueue",
referenced from: _OBJC_CLASS_$_MainCommandQueue in MainViewController.o "_OBJC_METACLASS_$_CDVViewController",
referenced from: _OBJC_METACLASS_$_MainViewController in MainViewController.o "_OBJC_CLASS_$_CDVViewController",
referenced from: _OBJC_CLASS_$_MainViewController in MainViewController.o "_OBJC_METACLASS_$_CDVCommandQueue",
referenced from: _OBJC_METACLASS_$_MainCommandQueue in MainViewController.o "_CDVPluginHandleOpenURLNotification",
referenced from: -[AppDelegate application: handleOpenURL: ] in AppDelegate.o
ld: symbol(s) not found
for architecture arm64
clang: error: linker command failed with exit code 1(use - v to see invocation)
In short how do I fix this?
Thanks

do the following steps
Select your Project icon
Choose Build Settings.
For "Architectures", select $ARCHS_STANDARD - Standard architectures
(armv7, armv7s, arm64)
For "Valid Architectures", add "arm64"
Select your CordovaLib.xcodeproj icon
In the Build Settings for the Project (not Target), delete the
conditional architecture settings (hover to see the minus sign)
For "Architectures", select $ARCHS_STANDARD - Standard architectures
(armv7, armv7s, arm64)
For "Valid Architectures", add "arm64"
Goto 6, but now do it for "Target"
if you found any issue please let me know.

There are a number of related answers for this situation, which stems from Apple adding arm64 to the default architectures in Xcode 5.1.
Looks like you are using cordova, so I'd start here:
xcode 5.1: libCordova.a architecture problems

Related

Apple Mach-O : Undefined symbols for architecture i386: in PhoneGap Cordova 2.9.1

I am new in phonegap app development in iOS. After adding CordovaLib.xcodeproj in my xcode project, I made architecture changes in buildsettings as suggested here. Other linker flag is -all_load and -Obj-C When I build the project, I get Apple Mach-O linker errors described below. I have not mentioned i386 anywhere in my build settings. How do I negate this error?
Undefined symbols for architecture i386:
"_CDVPluginHandleOpenURLNotification", referenced from:
-[AppDelegate application:handleOpenURL:] in AppDelegate.o
"_OBJC_CLASS_$_CDVPlugin", referenced from:
_OBJC_CLASS_$_LoginPlugin in LoginPlugin.o
"_OBJC_CLASS_$_CDVPluginResult", referenced from:
objc-class-ref in LoginPlugin.o
"_OBJC_CLASS_$_CDVViewController", referenced from:
_OBJC_CLASS_$_MainViewController in MainViewController.o
"_OBJC_METACLASS_$_CDVPlugin", referenced from:
_OBJC_METACLASS_$_LoginPlugin in LoginPlugin.o
"_OBJC_METACLASS_$_CDVViewController", referenced from:
_OBJC_METACLASS_$_MainViewController in MainViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Include WebRTC in iOS project

I trying to deal with the AppRTCDemo projet but I am getting error.
Which library I forget to include ?
Log error :
Undefined symbols for architecture armv7s:
"_OBJC_CLASS_$_RTCVideoRenderer", referenced from:
objc-class-ref in VideoView.o
"_OBJC_CLASS_$_RTCSessionDescription", referenced from:
objc-class-ref in AppDelegate.o
"_OBJC_CLASS_$_RTCICECandidate", referenced from:
objc-class-ref in AppDelegate.o
"_OBJC_CLASS_$_RTCVideoCapturer", referenced from:
objc-class-ref in AppDelegate.o
"_OBJC_CLASS_$_RTCPair", referenced from:
objc-class-ref in AppDelegate.o
"_OBJC_CLASS_$_RTCMediaConstraints", referenced from:
objc-class-ref in AppDelegate.o
"_OBJC_CLASS_$_RTCPeerConnectionFactory", referenced from:
objc-class-ref in AppDelegate.o
"_OBJC_CLASS_$_RTCICEServer", referenced from:
objc-class-ref in APPRTCAppClient.o
ld: symbol(s) not found for architecture armv7s
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Thanks
The solution is to set the "Other Linker Flags" in the build setting of your project to $(inherited).
Then it will be an inherited link options from the workspace.
Maybe this library isn't built for armv7s processors.
Is it static lib built in .a file?
If so, you can run in console lipo -info command to see what architectures is this library built for.
For example, this command for some library somelib.a lipo -info somelib.a gives output:
Architectures in the fat file: somelib.a are: armv7 i386
If armv7s architecture isn't supported, but armv7 is, you can also run your project, try setting this in your build options:
"Build Active Architecture Only" YES --> NO.
You may be testing on iPhone 5 or above which is on armv7s architecture (see http://iossupportmatrix.com/ for more info).
The AppRTCDemo was built on armv7, that assume to run it on devices issued between the iPhone 3GS and the iPad mini (that includes iPhone 4 and 4s).
Regards,
S.
you have to run the app in ios device....not in simulator

Xcode 5 and phonegap: linker errors on building for device but not for simulator

Our phonegap app builds fine for the iphone simulator but generates linker errors when building the app on an iphone. the only thing that changed was installing testflight and a test app.
We already removed testflight and the test app, but the linker errors remain.
Any ideas on how to fix this?
We're on xcode 5 and phonegap 3.4.
Errors:
ld: warning: ignoring file /Users/c/Library/Developer/Xcode/DerivedData/s-fhgxmhdprdjvwahdbgwuagoragit/Build/Products/Debug-iphoneos/libCordova.a, file was built for archive which is not the architecture being linked (arm64): /Users/c/Library/Developer/Xcode/DerivedData/s-fhgxmhdprdjvwahdbgwuagoragit/Build/Products/Debug-iphoneos/libCordova.a
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_CDVWebViewDelegate", referenced from:
objc-class-ref in CDVInAppBrowser.o
"_OBJC_METACLASS_$_CDVViewController", referenced from:
_OBJC_METACLASS_$_MainViewController in MainViewController.o
"_OBJC_CLASS_$_CDVPlugin", referenced from:
_OBJC_CLASS_$_CDVDevice in CDVDevice.o
_OBJC_CLASS_$_CDVConnection in CDVConnection.o
_OBJC_CLASS_$_LowLatencyAudio in LowLatencyAudio.o
_OBJC_CLASS_$_CDVLogger in CDVLogger.o
_OBJC_CLASS_$_CDVInAppBrowser in CDVInAppBrowser.o
_OBJC_CLASS_$_InAppPurchase in InAppPurchase.o
"_OBJC_METACLASS_$_CDVPlugin", referenced from:
_OBJC_METACLASS_$_CDVDevice in CDVDevice.o
_OBJC_METACLASS_$_CDVConnection in CDVConnection.o
_OBJC_METACLASS_$_LowLatencyAudio in LowLatencyAudio.o
_OBJC_METACLASS_$_CDVLogger in CDVLogger.o
_OBJC_METACLASS_$_CDVInAppBrowser in CDVInAppBrowser.o
_OBJC_METACLASS_$_InAppPurchase in InAppPurchase.o
"_OBJC_CLASS_$_CDVViewController", referenced from:
_OBJC_CLASS_$_MainViewController in MainViewController.o
objc-class-ref in CDVDevice.o
"_CDVLocalNotification", referenced from:
-[AppDelegate application:didReceiveLocalNotification:] in AppDelegate.o
"_OBJC_METACLASS_$_CDVCommandDelegateImpl", referenced from:
_OBJC_METACLASS_$_MainCommandDelegate in MainViewController.o
"_OBJC_CLASS_$_CDVPluginResult", referenced from:
objc-class-ref in CDVDevice.o
objc-class-ref in CDVConnection.o
objc-class-ref in LowLatencyAudio.o
objc-class-ref in CDVInAppBrowser.o
objc-class-ref in InAppPurchase.o
"_OBJC_CLASS_$_CDVCommandDelegateImpl", referenced from:
_OBJC_CLASS_$_MainCommandDelegate in MainViewController.o
"_OBJC_CLASS_$_CDVUserAgentUtil", referenced from:
objc-class-ref in CDVInAppBrowser.o
"_OBJC_CLASS_$_CDVCommandQueue", referenced from:
_OBJC_CLASS_$_MainCommandQueue in MainViewController.o
"_OBJC_METACLASS_$_CDVCommandQueue", referenced from:
_OBJC_METACLASS_$_MainCommandQueue in MainViewController.o
"_CDVPluginHandleOpenURLNotification", referenced from:
-[AppDelegate application:handleOpenURL:] in AppDelegate.o
-[CDVInAppBrowser openInSystem:] in CDVInAppBrowser.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This kind of problems occur while updating your Xcode but any third party tool you are using may not be updated with this architecture armv64.
So Click on your Project Navigator from XCode.
Click On Targets from your Project and click on BuildSettings from it.
Find Valid Architectures in it.
Just double click on that and remove armv64 from that.
Make sure there is armv7 and armv7s only.
In my case this worked for me.
Clean and build your project. It should work fine now.
Hope it helps you.
EDIT
Now, as of Feb 1st 2015, apple will not allow apps without arm64 architecture supported.
So make sure that all the apps submitted have arm64 support.
seems like we also unintentionally upgraded to xcode 5.1, causing the problem. phonegap 3.4 and xcode 5.1 are incompatible unless you make some changes.
here is the solution: http://shazronatadobe.wordpress.com/2014/03/12/xcode-5-1-and-cordova-ios/
Sorry if this might seem like a trite answer, but the following steps are usually what I always do when I see linker errors :
Ensure your code is up to date, with all the latest fixes and versions.
Make sure you update your submodules. In git : git submodule update --init --recursive
Please do a Clean Build Folder : Go to Product, Hover on Clean and press together (Command + Option) and click on "Clean Build Folder".
Rinse and Repeat.
In case you have any modules that are not being references correctly, head over to your Build Phases, REMOVE the modules that are troubling you and re-add them.

Google Analytics doesn't work on new iOS project

I have created a new iOS project and added Google Analytics support following by official instructions.
I've added to Frameworks:
libGoogleAnalyticsServices.a
AdSupport.framework
CoreData.framework
SystemConfiguration.framework
libz.dylib
But it doesn't work with the errors:
ld: warning: directory not found for option '-L/Users/.../Sources/GoogleAnalytics'
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_NSManagedObjectModel", referenced from:
objc-class-ref in libGoogleAnalyticsServices.a(GAICoreDataUtil.o)
"_OBJC_CLASS_$_NSAttributeDescription", referenced from:
objc-class-ref in libGoogleAnalyticsServices.a(GAICoreDataUtil.o)
"_OBJC_CLASS_$_NSEntityDescription", referenced from:
objc-class-ref in libGoogleAnalyticsServices.a(GAIDataStore.o)
objc-class-ref in libGoogleAnalyticsServices.a(GAICoreDataUtil.o)
"_OBJC_CLASS_$_NSPersistentStoreCoordinator", referenced from:
objc-class-ref in libGoogleAnalyticsServices.a(GAIDataStore.o)
"_OBJC_CLASS_$_NSFetchRequest", referenced from:
objc-class-ref in libGoogleAnalyticsServices.a(GAIDataStore.o)
"_OBJC_CLASS_$_NSManagedObjectContext", referenced from:
objc-class-ref in libGoogleAnalyticsServices.a(GAIDataStore.o)
"_NSSQLiteErrorDomain", referenced from:
-[GAIDataStore performBlockAndWait:withError:] in libGoogleAnalyticsServices.a(GAIDataStore.o)
"_NSSQLiteStoreType", referenced from:
-[GAIDataStore coordinatorWithModel:URL:] in libGoogleAnalyticsServices.a(GAIDataStore.o)
"_NSOverwriteMergePolicy", referenced from:
-[GAIDataStore contextWithModel:URL:] in libGoogleAnalyticsServices.a(GAIDataStore.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
How can I fix it? And does it support arm64?
From Google Analytics developer page
The Google Analytics SDK uses the CoreData and SystemConfiguration frameworks, so you will need to add the following to your application target's linked libraries:
libGoogleAnalyticsServices.a
AdSupport.framework
CoreData.framework
SystemConfiguration.framework
libz.dylib
Looks like you are missing out CoreData.framework.
Running the lipo -info command on the GA library.
xcrun -sdk iphoneos lipo -info libGoogleAnalyticsServices.a
Gives result,
Architectures in the fat file: libGoogleAnalyticsServices.a are: armv7 armv7s i386 x86_64 arm64
So it does support arm64.
Hope that helps!
Thanks for all! The following steps helped me:
Remove CoreData.framework.
Add again CoreData.framework.
arm64 is now supported. Thanks to Amar.
Now I should fix the last warning:
ld: warning: directory not found for option '-L/Users/.../Sources/GoogleAnalytics'
It happens because I work with the project on different users.
You should add the libsqlite3.0.dylibfile to your frameworks.
To do this, under the projects target, on the general tab, you will find "Linked Frameworks and Libraries", just select the '+' button, and add the framework from there

phonegap cordova xcode link failed when build to 64bit

i have a cordova project in xcode 5.0.2 it works perfectly on a iphone5c but didnt work on iphone5s
i read some on this and thought that the problem is i have to build my project on 64bit architecture.
i make this build settings:
architecture - standart architecture (including 64-bit)(armv7, armv7s, arm64)
build active architecture only - no
and when i build i get this errors:
ld: warning: ignoring file /Users/chana/Library/Developer/Xcode/DerivedData/Pitaron- echagbyhunbeprbdfodckoblgtuq/Build/Products/Debug-iphonesimulator/libCordova.a, file was built for archive which is not the architecture being linked (x86_64): /Users/chana/Library/Developer/Xcode/DerivedData/Pitaron-echagbyhunbeprbdfodckoblgtuq/Build/Products/Debug- iphonesimulator/libCordova.a
Undefined symbols for architecture x86_64:
"_CDVLocalNotification", referenced from:
-[AppDelegate application:didReceiveLocalNotification:] in AppDelegate.o
"_CDVPluginHandleOpenURLNotification", referenced from:
-[AppDelegate application:handleOpenURL:] in AppDelegate.o
"_OBJC_CLASS_$_CDVCommandDelegateImpl", referenced from:
_OBJC_CLASS_$_MainCommandDelegate in MainViewController.o
"_OBJC_CLASS_$_CDVCommandQueue", referenced from:
_OBJC_CLASS_$_MainCommandQueue in MainViewController.o
"_OBJC_CLASS_$_CDVViewController", referenced from:
_OBJC_CLASS_$_MainViewController in MainViewController.o
"_OBJC_METACLASS_$_CDVCommandDelegateImpl", referenced from:
_OBJC_METACLASS_$_MainCommandDelegate in MainViewController.o
"_OBJC_METACLASS_$_CDVCommandQueue", referenced from:
_OBJC_METACLASS_$_MainCommandQueue in MainViewController.o
"_OBJC_METACLASS_$_CDVViewController", referenced from:
_OBJC_METACLASS_$_MainViewController in MainViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
any body knows what to do?
thanks a lot.
The problem is with Xcode 5.1 coming with 64 bit support.
The cordova project created contains cordova library (‘CordovaLib.xcodeproj’ project in the project navigator pane) which is not configured for arm64.
To resolve this issue, click on ‘CordovaLib.xcodeproj’ where it shows project settings goto ‘Architectures’ and table and change all architectures to ‘$(ARCHS_STANDARD)’ or Standard Architectures. (They have been initially set to different values which is the reason for build failing)
The problem seems to be that your version of libCordova isn't compiled for arm64.
The quick fix is to remove arm64 from your list of build architectures - the 5s will happily run code compiled for armv7.
The proper fix is to upgrade Cordova to a version that has arm64 versions of the libraries compiled.

Resources