Undefined symbols for architecture x86_64 while using a static library - ios

I created a static library (XXX.a) (which has 3 static libraries inside(aaa.a, bbb.a, ccc.a)) and added it into a pre-developed project (someonesProject). When I lipo -info to XXX.a I see the following architectures: armv7, i386, x86_64, arm64
When I try to run this project, I receive an error:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_aaa", referenced from:
objc-class-ref in XXX.a(XXX.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
When I remove arm64 from the valid-architectures (arm64, armv7 armv7s) of the project (someonesProject), then I can run the app.
How can I fix this issue, I want to make this project work without removing arm64?
I really need help.
Thanks
E.

All your static libraries have to be compatible with arm64 if you want to compile your project with this architecture.
So I guess at least one of aaa.a, bbb.a and ccc.a is not compatible with arm64.

Related

ld: symbol(s) not found for architecture x86_64 Xcode 10.3

I am trying to run a project with objective C and with a private SDK
and I get the error
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_DetectionSDK", referenced from:
objc-class-ref in ViewController.o
objc-class-ref in AppDelegate.o
objc-class-ref in SecondViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Is weird (for me) because in the real iphone runs (and in xcode 11), but in the simulator does not
Looks like your private SDK doesn't contains simulator slices.
To check this, run command lipo -i path\to\your_private_sdk\your_private_sdk.
Output should contains something like i386 x86_64 armv7 arm64
% lipo -i your_private_sdk
Architectures in the fat file: your_private_sdk are: i386 x86_64 armv7 arm64
If it contains only armv7 arm64 architectures, you need to create universal framework from your private SDK.
More details you can find here:
How to create universal (fat) library
You can try -
1:) delete the app from simulator , clean and build again.
2:) try to reinstall that private sdk & then .clean and build.

Xcode 9.4.1: Undefined symbols for architecture armv7, arm64, x86_64

I created a framework using CMake and added it to the test project. Then import the header file and everything works fine. I got this error when I call the method. I don't know why this error occurs. I tried almost all possible ways, but it didn't work. Any suggestions will be grateful.
Issue
Undefined symbols for architecture armv7:
"XmlInterface::XmlInterface()", referenced from:
-[ViewController viewDidLoad] in ViewController.o
"XmlInterface::~XmlInterface()", referenced from:
-[ViewController viewDidLoad] in ViewController.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have tried these methods
Other Linker Flags add $(inherited)
delete DerivedData
set NO to Active Architecture Only
lipo -info
Architectures in the fat file: xml are: x86_64 armv7 armv7s arm64
Attached screenshot
Project structure
Your compiling with a binary that has been compile on simulator, but try to run the app on a real device.
The simplest way is to compile on device, then run on device. The hardest way is to check what can be done with "lipo" :)

IOS linking with missing architecture i386 (AdSupport.framework)

I had this question going on, but now I am a little further:
I added this framework to my project:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/AdSupport.framework
Now this works fine if I run the app on any device, however this framework is just for the architectures armv7, armv7s and arm64
When running the app on the simulator, the build fails because the architecture i386 is missing. This is included in:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/AdSupport.framework
How can I achieve that all architectures can be used? I played a lot with the build-settings but nothing worked so far!
error report:
ld: warning: ignoring file /Users/XXXXXXX/Documents/app1/app1/AdSupport.framework/AdSupport, missing required architecture i386 in file /Users/XXXXXXX/Documents/app1/app1/AdSupport.framework/AdSupport (3 slices)
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_ASIdentifierManager", referenced from:
objc-class-ref in libGoogleAdMobAds.a(GADDevice.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Thanks a lot!
Go to the Project Target.and make architecture like below image.
/Users/XXXXXXX/Documents/app1/app1/AdSupport.framework/AdSupport is missing an i386 slice; I suspect that it was likely built for arm and not intel. It looks like that framework is external to your project, so I suggest you rebuild it for the simulator.
You can check the current architectures of the framework by running file /Users/XXXXXXX/Documents/app1/app1/AdSupport.framework/AdSupport

Adding Testflight SDK: missing required architecture arm64 in file libTestFlight.a

I'm adding the Testflight SDK to my iOS project, but now I can't build the IPA for it.
The error I have is
ld: warning: ignoring file /Users/RM/Dropbox/SAM_iOS/mainApp/SAM/TestFlightSDK2/libTestFlight.a, missing required architecture arm64 in file /Users/RM/Dropbox/SAM_iOS/mainApp/SAM/TestFlightSDK2/libTestFlight.a (3 slices)
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_TestFlight", referenced from:
objc-class-ref 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)
I've followed (three times) the steps detailed here, but the error keeps appearing.
Any help is appreciated!
The 2.0.2 version of the TestFlight library does not support arm64.
You can either remove the arm64 from your project and targets or use the 2.1 beta library which has support for arm64
You can check which architectures are included in the a library using the lipo tool in Terminal:
lipo -info <path to library>
Running this on version 2.0.2 of the library, shows that it does not include the arm64 architecture:
Architectures in the fat file: libTestFlight.a are: armv7 armv7s i386
Running the same on the 2.1.3 beta:
Architectures in the fat file: libTestFlight.a are: armv7 armv7s i386 x86_64 arm64

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