error when including my static library in an iOS project - ios

I'm trying to include a static library in an iOS project.
I imported the .a file and every .h related but then I'm getting this error :
ld: warning: ignoring file /Users/alexis/Library/Developer/Xcode/DerivedData/PlazappPartnerWorkspace- cdrmloavlcqouugawmtqywiinqne/Build/Products/Debug-iphoneos/libPlazappPartnerLib.a, file was built for archive which is not the architecture being linked (i386)
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_LauncherViewController", referenced from:
objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I guess there's a problem of architecture type but I don't understand why nor how to solve it.
Can someone explain it to me and tell me how to solve it? Thanks!

It seems your library was built to run in the device (arm architecture) and you try to use it in the simulator (i386 architecture). Check your library build settings. They should match with your project build settings.
Or even better, create a fat library for development purposes. lipo command is your friend.
To verify the current architectures present in your library: (in Terminal)
cd <path to library folder> # in you case: /Users/alexis/Library/Developer/Xcode/DerivedData/PlazappPartnerWorkspace- cdrmloavlcqouugawmtqywiinqne/Build/Products/Debug-iphoneos
lipo -info libPlazappPartnerLib.a
The output should look like:
Architectures in the fat file: libPlazappPartnerLib.a are: armv6 armv7
They should match with the target device or simulator you are building for.

Related

Xcode 8.1 Undefined symbols for architecture x86_64 Error

Undefined symbols for architecture x86_64:
"_BROADCAST_MODE_IBEACON", referenced from:
-[MainViewController tableView:cellForRowAtIndexPath:] in MainViewController.o
"_OBJC_CLASS_$_TZBeaconSDK", referenced from:
objc-class-ref 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)
I take that error when I want to use simulator. There is no problem when I build it on iPhone. There is only problem when I use simulator. I have tried to change Architectures from Build settings, error text changes as i386 but problem is same.
I use that sdk; TZBeacon
Is there any problem with sdk? Could you help me to solve that problem?
Your library does not support simulator. Run this command line to see which architecture that it supports:
lipo -info libTZBeaconSDK.a
the result is: Architectures in the fat file: libTZBeaconSDK.a are: armv7 arm64
So, you have to test in a device, not in simulator!
Typically you get that error in the simulator if the architecture of the framework is built for the device. You need to use a version of the framework that is built for the simulator to run it on the simulator. This is something that should be provided by the framework vendor.
If they don't provide one then look into only including that framework when building to the device and not to the simulator. There is another SO answer here to point you in the right direction: How to only include a framework when building for device, not iOS Simulator?
Simple trick here: Go -> Go To Folder "/Library/Developer/Xcode"
delete Derived data next clean your project then Run .

Can't build project with MobileVLCKit (XCode)

I'm trying to make a single view application for iOS and tvOS with MobileVLCKit.
I downloaded files from git.
I ran ./buildMobileVLCKit.sh with -f key and got a framework ("MobileVLCKit.framework" folder containing MobileVLCKit binaty and Headers subfolder).
I temporary put the framework into ~/Desktop/FrameworkFolder/
I created new project in XCode, chose "File->Add files" and located the framework.
Added Framework Search Path in Project Options (~/Desktop/FrameworkFolder/, recursive).
Added #import into ViewController.h file.
Added VLCMediaPlayer *vPlayer = [[VLCMediaPlayer alloc] init]; into ViewController.m -> viewDidLoad method.
This is my binary:
imac:~ vlad$ file ~/Desktop/FrameworkFolder/MobileVLCKit.framework/MobileVLCKit
/Users/vlad/Desktop/FrameworkFolder/MobileVLCKit.framework/MobileVLCKit: Mach-O universal binary with 5 architectures
/Users/vlad/Desktop/FrameworkFolder/MobileVLCKit.framework/MobileVLCKit (for architecture armv7): current ar archive random library
/Users/vlad/Desktop/FrameworkFolder/MobileVLCKit.framework/MobileVLCKit (for architecture armv7s): current ar archive random library
/Users/vlad/Desktop/FrameworkFolder/MobileVLCKit.framework/MobileVLCKit (for architecture i386): current ar archive random library
/Users/vlad/Desktop/FrameworkFolder/MobileVLCKit.framework/MobileVLCKit (for architecture x86_64): current ar archive random library
/Users/vlad/Desktop/FrameworkFolder/MobileVLCKit.framework/MobileVLCKit (for architecture arm64): current ar archive random library
When I try to build and run the project I'm getting two types of errors:
If I'm working with AppleTV project:
ld: in /Users/vlad/Desktop/FrameworkFolder/MobileVLCKit.framework/MobileVLCKit(VLCMediaPlayer.o), building for tvOS, but linking in object file built for iOS, for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
If I'm working with iOS project:
Undefined symbols for architecture x86_64:
"_AVAudioSessionCategoryPlayback", referenced from:
_Start in MobileVLCKit(audiounit_ios.o)
_Pause in MobileVLCKit(audiounit_ios.o)
"_AVAudioSessionModeMoviePlayback", referenced from:
_Start in MobileVLCKit(audiounit_ios.o)
_Pause in MobileVLCKit(audiounit_ios.o)
"_AudioComponentFindNext", referenced from:
_Start in MobileVLCKit(audiounit_ios.o)
"_AudioComponentInstanceDispose", referenced from:
_Stop in MobileVLCKit(audiounit_ios.o)
— at the begining, and:
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Showing first 200 notices only
— at the end of output. And 155 critical errors between.
I have tried to use precompilled framework as well, same result.
The questions are:
What am I doing wrong?
How can I solve this issue and successfully
build and run the project(s)?
Thank you for any help!
The reason of ld and clang errors was that the Framework and the Library has been built wrong.
The reason of multiple errors during working with iOS project is that required system frameworks has not been included.
I built the static library using XCode and the issue has been solved!

XCode 6.1 Missing required architecture X86_64 in file for extern library

I have an issue when trying to use an external lib : I can't compile the project as it throws an exception as below.
ld: warning: ignoring file /Users/renaudcousin/Documents/XCode/WORK/StimShopPOC/StimShopPOC/libStimshop_SDK.a, missing required architecture x86_64 in file /Users/renaudcousin/Documents/XCode/WORK/StimShopPOC/StimShopPOC/libStimshop_SDK.a (3 slices)
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_StimshopSDK", referenced from:
objc-class-ref in ViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)`
I tried lots of solutions found on stackoverflow (but for XCode 5.1 and not as well explained) without any change ...
I also found this topic XCode 6.1 Missing required architecture X86_64 in file that exactly correspond to my problem and
when looking at my lib's architecture with lipo -info command, it seems it's missing i386 and x86_64. How could I add them to my library architectures to be able compile ?
This means your .a library doesn't contain the x86_64 architecture (You can run lipo -info /path/to/your/lib.a to verify it). If you don't have the source code of the library, you have to modify your own project. In the build settings, change the valid architectures to armv7 and i386, or change Architectures to armv7 only. However, by doing so, your project won't be compiled to the arm64 architecture, which is required when uploading to the App Store after Feb 2015, according to Apple's announcement.
If your library doesn't contain x86_64 architecture, it is likely that it doesn't contain arm64 either. So you should avoid using old libraries.
If a library doesn't have the X86_64 architecture you can build it if you've picked a connected device rather than a simulator for your build target.
Basically, you can still build and develop but you can't use the simulator.
Click on your project > build setting > architecture. Change architecture as armv7 and delete others like armv6,etc, Then it will work :-
In the project that builds libStimshop_SDK.a, be sure the "Architectures" setting is set to $(ARCHS_STANDARD) and that it includes 64-bit settings in the compiler settings. Be sure the "Valid Architectures" setting includes 64-bit as well.

add framework to static library xcode

i am trying to add this mpos.framework to my Static library but i get this :
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_MPMpos", referenced from:
objc-class-ref in libSerenity.a(Widget.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
i should add the mpos.framework to the DependentApp also?
i should add the mpos.framework to the DependentApp also? - You can easily answer this by trying it.
My guess is that this is not your problem. It looks like mpos.framework (and its internal library) is not FAT library and is compiled for ARM architecture(s) only. It probably do not contain i386 (simulator) version of the compiled code. You can find more information about FAT libraries here: Build fat static library (device + simulator) using Xcode and SDK 4+

Static Library and XCode 4.x

We've implemented a static library and trying to use it on the project. The library is compiled/build well but as we try to run the project after importing .a & .h files respectively, we encountered with following error :
ld: warning: ignoring file Lib.a, file was built for archive which is not the architecture being linked (i386)
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_MFourInOneStaticLib", referenced from:
objc-class-ref in MAppDelegate.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 already checked the architecture.More-over, we're using the simulator for the testing purpose.
well looks the your lib doesnt contain the right architecture.
for ios you need armv7 and for the simulator you need i386
to test it
lipo -info %NAME%
often a lipo is only built for EITHER arm OR x86
built it for both archs and then combine the two files
lipo ./build/Release-iphoneos/%NAME% ./build/Release-iphonesimulator/%NAME% -output ./Dist/lib/%NAME% -create

Resources