Linker command failed with exit code architecture i386 xcode - facebook

I have an app that I am using various other Frameworks and libraries in.
FacebookSDK, GoogleSignIn, libsqlite3
I have included these in my buildSettings and even put Facebook in my Frameworks path and libxml2 in the Header Search Path.
However when I build in the simulator I get 21 errors which say
"linker command failed with exit code 1
ld: symbol(s) not found for architecture i386
this only happens with the simulator not on any device.
I am attaching a screen shot.
Any ideas would help. I have look at a lot of questions with this with no solution.

The lines in yellow are telling you the problem. When you compile for the simulator you are producing i386 code, for a real device you are producing ARM code. The libraries you are using do not contain i386 code, hence the errors.
You need to obtain versions of the libraries with i386 code.
HTH

Related

Xcode Build Failure on Archive, but not on Run with ResearchKit

I'm trying to build a project that has ResearchKit in it, and whenever I build and run on a physical device (or the simulator, for that matter) it works fine. But when I attempt to Archive it, I get the following error:
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_ORKVisualConsentStep", referenced from:
objc-class-ref in InformedConsent.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I followed the installation guidelines on the ResearchKit GitHub, and made sure to check that researchKit.framework was under the Frameworks, Libraries and Embedded Content section as well as the "Link Binary With Libraries" section of the build phases tab (as was described in this link as well as a couple others: Xcode build failure "Undefined symbols for architecture x86_64") but still nothing.
Is there something I'm doing wrong, or another setting I might be able to change?
UPDATE:
I noticed that the element that was throwing the error - ORKVisualConsentStep - was deprecated a few iOS versions ago. So by taking that out, I was able to get the project to archive.
I didn't want to put this as the accepted answer, though, because I wanted to see if there was a better solution than just deleting code.
Thanks for your help!

ignoring file [path] missing required architecture i386 in file

I'm quite new to Xcode and Iphone development and ran into the following problem:
I opened a new project and added *.h and a *.a files (which I recived from a certain device vendor).
I get the following warning:
ld: warning: ignoring file /Users/udi/Desktop/Xcode/Xcode Projects/Scosche/libmyTrekSDK_armv7.a, missing required architecture i386 in file /Users/udi/Desktop/Xcode/Xcode Projects/Scosche/libmyTrekSDK_armv7.a (2 slices)
If I ignore the warning, and try to instanciate the class that is given to me in the header file, I get these errors:
ld: warning: ignoring file [Path/FileName.a], missing required architecture i386 in file [Path/FileName.a] (2 slices)
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_HRMonitor", referenced from:
objc-class-ref in ViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
I've checked the Framework Search Pathes (as mantioned in many other posts) and it clear.
More info:
I'm Using Xcode 4.6.1
The files are currently located at project's root folder.
I'm using a Single View Application tamplate.
Appreciate any help
This warning means that you're trying to use library made for Device (ARM) with your Simulator (i386).
You can use this terminal command to create a universal library:
lipo -create lib_arm.a lib_i386.a -output lib_universal.a
More info about lipo command here.
Change your target's "Build Settings > Build Active Architectures Only" to "No"
This is doing the same thing as Dmitry Zhukov's answer but doing it thru Xcode instead of going around its back.
If you are working with a 3rd party code, keep in mind that some SDKs may not work on the simulator. The same build error I have encountered vanished, when I ran the project on the device.

iPhone Static Library Issues With Simulator

So I have an iPhone static library that I am trying to build. I've got the script that was used in this question (http://stackoverflow.com/questions/3520977/build-fat-static-library-device-simulator-using-xcode-and-sdk-4), but the issue I've hit is that I'm seemingly still unable to successfully build the static library for the simulator. When I build in the static library project, I get the follow warnings:
warning: no rule to process file '$(PROJECT_DIR)/GDInAppStore/GDInAppStore.m' of type sourcecode.c.objc for architecture i386
warning: no rule to process file '$(PROJECT_DIR)/GDInAppStore/SKProduct+priceAsString.m' of type sourcecode.c.objc for architecture i386
warning: no rule to process file '$(PROJECT_DIR)/GDInAppStore/VerificationControllerPBK.m' of type sourcecode.c.objc for architecture i386
I believe this issue is causing the problem that is leading to the universal library I get from the build script causing this error in my other project
ld: warning: ignoring file /Users/abotkin/Projects/Static Libraries/GDInAppStore/libGDInAppStore.a, missing required architecture i386 in file
"_OBJC_CLASS_$_GDInAppStore", referenced from:
objc-class-ref in SubscribeNowInAppController.o
ld: symbol(s) not found for architecture i386
I'm using Xcode 4.3.2 and have set the flags in the static library Xcode project so that i386 is included in the Architecture and Valid Architectures. Any tips?
Make sure you are building for the simulator if you are compiling for i386. Basically, your arch parameter has to match your sdk parameter. i.e.
xcodebuild -project proj.xcodeproj -arch armv64 -sdk iphoneos8.1 build
and
xcodebuild -project proj.xcodeproj -arch i386 -sdk iphonesimulator8.1 build
I was able to do a workaround this issue by using Karl's iOS Universal Framework that he mentioned in the other topic here https://stackoverflow.com/a/5721978/497718
That said, if anyone could point me into what I may have been doing wrong in using the script in that same topic, I'd love to learn how to do it the right way.
With Xcode 6, Apple has added iOS framework support to their build tools.
Using Apple's framework target for all new projects, as it is less hacky and is supported by Apple themselves.

recieved apple O Linker Error when adding ASIHTTPRequest

this has made me crazy today, I use ASIHTTPRequest, http://allseeing-i.com/ , already, but here, am trying now to add it to an app, once added it gave me this crazy error.
I have started a new fresh project, and commented all related code, added the code without it, and yes, it works, added it, and it's libraries and no it doesn't work and I got this crazy Error, I'm stuck and need help.
BTW, this is the detailed error,
ld: warning: ignoring file /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.0/Symbols/usr/lib/libz.1.2.3.dylib, missing required architecture i386 in file
ld: warning: ignoring file /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.0/Symbols/usr/lib/libSystem.dylib, missing required architecture i386 in file
ld: in /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.0/Symbols/usr/lib/libobjc.A.dylib, missing required architecture i386 in file 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
Thank you,
Regards,
Ahmed
I got the answer now.
I have copied the older version, a working version of my app. Or just create a new project and add the files that are not related to this, and make sure it's working and building.
Then, Added the frameworks from project setting (first icon on left) and then added from the build phase the correct libraries.
My problem was : I was trying to add the libraries by dragging them into my project, and the problem was specially for this one. libz.1.2.3.dylib. Thank you anyways, hope this is helpful for someone.

Why won't my project run in the iPhone Simulator?

For some reason, my application will install and run fine on my device, but when I try to install my application on the iPhone Simulator, I get these warnings:
ld: warning: in /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk/System/Library/Frameworks/UIKit.framework/UIKit, missing required architecture i386 in file
ld: warning: in /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk/System/Library/Frameworks/Foundation.framework/Foundation, missing required architecture i386 in file
ld: warning: in /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics, missing required architecture i386 in file
ld: warning: in /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk/System/Library/Frameworks/CFNetwork.framework/CFNetwork, missing required architecture i386 in file
ld: warning: in /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk/System/Library/Frameworks/AudioToolbox.framework/AudioToolbox, missing required architecture i386 in file
ld: warning: in /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk/System/Library/Frameworks/MobileCoreServices.framework/MobileCoreServices, missing required architecture i386 in file
ld: warning: in /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk/System/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration, missing required architecture i386 in file
ld: warning: in /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore, missing required architecture i386 in file
And that causes a bunch of errors that just occur when those frameworks are just not present. Errors like:
"_OBJC_CLASS_$_NSMutableCharacterSet", referenced from: objc-class-ref-to-NSMutableCharacterSet in SBJsonWriter.o
The Answer is:
1) The Base SDK should be Device
2) iPhone SDK Frameworks were copied into your project directory (on disk). Open your project directory and remove any standard iPhone SDK Frameworks.
3) Clean Caches and Rebuild
I had the same problem. It was due to dragging frameworks from one project to another with the Copy option enabled.
Even though I had later de-referenced these frameworks, and added them correctly, it still gave me these errors until I had deleted the framework directories from the project.
It is attempting to build against the device libraries for use on the simulator. The paths should look like:
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.0.sdk/System/Library/Frameworks/UIKit.framework/UIKit
... with iPhoneSimulator.platform instead of iPhoneOS.platform. Check your build settings, clean the project and empty the Xcode cache(Xcode>Empty Cache...).
If I'm not mistaken, if you use base SDK > 3.2, you should set the architecture to optimized. Which is armv7.
I'm not sure though.
~ Natanavra.
I think that you set iPhone Device x.x instead of iPhone Simulator x.x as the base SDK.
A similar thing hapend to me, when I did that.
I figured out a fix. I set the base SDK to iPhone Simulator 4.0, and because it still tried to get SDKs from the iPhoneOS, I renamed iPhoneOS.platoform to iPhoneOS_2.platform so Xcode cannot access the SDKs from that platform.
You need to go to build on the top menu bar and press the option clean all targets