Undefined symbol: _OBJC_CLASS_$_FIRApp - objective-c

I m trying to add Firebase Analytic and Firebase Crashlytics using Swift package manager here is a link of git for firebase SDK
https://github.com/firebase/firebase-ios-sdk
after that I add this two line in my AppDelegate file
#import <FirebaseCore/FIRApp.h>
#import <Firebase.h>
All fine until when I add this [FIRApp configure]; getting error
Undefined symbols for architecture arm64:
"OBJC_CLASS$_FIRApp", referenced from:
objc-class-ref in HWOFAppDelegate.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I go thought every link of stack-overflow for similar problem try every solution but nothing help me like change Other Linker Flag etc...
Please help me..I really appreciate...I m using Xcode 12.1 with Objective-C
here is a screenshot of error which i m getting
And screenshot of added dependency

After so much searched I solved issue. Solution is
"$(inherited)" In Other Linker Flags
Build Active Architecture Only value to "Yes"
Add Run Script for firebase SPM is "${BUILD_DIR%Build/*}SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run"
Clean project
Build Project

I got the same issue while integrating MLKit in my recent work. The app was running fine on simulator as well as device but when I tried to archive the build it started throwing me error below-:
Undefined symbol: _OBJC_CLASS_$_MLKFaceDetector
I am using the MLKFaceDetector object in my files.
Resolution:-
Go to Build Settings -> Architectures -> Replace standard architectures with arm64. Also, make sure there is no space between arm & 64.
Reason what I understood is MLKit only supports 64 bit not 32 bit and since we are using standard architectures targeting both 32 and 64 bit, so Xcode while archiving for 32 bit is unable to find MLKit files. So we are explicitly saying Xcode to Archive only for 64 bit and not 32 bit.
Cons - It will not support some of the older iOS devices.

Finally I found the solution for this
For me changing ios deployment target to higher version than before workd.Mine was 9.0 I changed it to 13 .
Target-general- deployment info

Can try this it Will help,
Change Linking -> Mach-O Type to Dynamic Library, for the frameworks you used, then it works fine.

Related

How to solve "Undefined symbols for architecture x86_64:"?

I've done hours and hours of searching and still no luck (read a lot of stackoverflow as well).
I am trying to implement FDTake via Cocoapods. When I try and run it I get the following:
undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_FDTakeController", referenced from:
objc-class-ref in VendeViewController.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 know there is many similar questions around SO but all their solutions don't seem to work for me.
From the logs I can assume that you would be using a static library which is not build for simulator(architecture x86_64).
The library is only compiled for device and it needs to be complied and build for simulator also. Then the two static files (one abc.a for device and one abc.a for simulator) needs to be fat file i.e these files should be merged together using lipo command on terminal to create a fat file. Now when you use this fat file it will work both for simulator as well as device.
But the important thing is that you should have the source to compile and build the static libraries for simulator and device. After which you merge these to create a fat file which will work on all the defined architectures.
In case you are using third party static library (SDK) then you need to contact the respected party.

Building OS X Native App With FireBase Template and Xcode 4.6.3

I am trying to build a native OS X app with the new Firebase Templates:
Firebase Gitub
I am encountering linker errors, that make me think the definition of the class FServerValues is missing:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_FServerValues", referenced from:
objc-class-ref in Firebase(FRepo.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Has anyone else tried to build a simple project using the Firebase Templates in Xcode 4.6.3? If so did you get these errors? Were you able to fix them?
Should be fixed now. Please replace your copy of Firebase.framework with the latest one, available here: https://www.firebase.com/docs/downloads.html
Apologies for the oversight, and please let me know if you run in to any more trouble.

Compiling libjpeg for iOS

I am trying to compile a project for iOS 6 in XCode, and I am using the following headers, which include the functionality I need:
#include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
#include "transupp.h" /* Support routines for jpegtran */
Those are straight out of jpegtran utility sources. I have installed the jpeg library before, and there is libjpeg.a in my /usr/local/lib/.
However when I try to compile, I am getting an error "Undefined symbols for architecture i386" or "Undefined symbols for architecture armv7", depending on whether target is an iPhone simulator or not.
Here are the keywords it can't find symbols for:
"_jpeg_stdio_src"
"_jpeg_finish_compress"
"_jcopy_markers_execute"
"_jpeg_copy_critical_parameters"
"_jtransform_adjust_parameters"
"_jpeg_destroy_compress"
"_jtransform_execute_transform"
"_jpeg_finish_decompress"
"_jpeg_read_header"
"_jtransform_request_workspace"
"_jpeg_write_coefficients"
"_jpeg_read_coefficients"
"_jpeg_destroy_decompress"
"_jpeg_stdio_dest"
"_jcopy_markers_setup"
I have encountered the missing symbol errors before, and always ended giving up on using 3rd party libraries, but in that particular case there's no way around.
What am I doing wrong here?
EDIT: I have added libjpeg.a to project settings and it did go further, but stopped now at:
Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
Target: i386-apple-darwin12.2.0
Thread model: posix
"lots-of-debug-paths"
ld: library not found for -ljpeg
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I recently needed libjpeg for iOS too (as a dependency of another third party library)
I ended up simply using the libjpeg-turbo, which comes with a precompiled fat binary
Architectures in the fat file: libjpeg.dylib are: i386 x86_64 armv6 armv7 armv7s arm64
I dunno how you compiled it. But you need to change the make install in order to compile it in i386 and armv7. I'm pretty sure you just run the make, so it compiled it for you mac, which is certainly a x84_64 arch, and this is certainly not what you want
You can check with
lipo -info /usr/local/lib/libjpeg.a // if libjpeg.a is at this path
or
file /usr/local/lib/libjpeg.a

Duplicate symbol _OBJC_CLASS_$_Facebook

I'm building an ARC iphone app, and about to integrate the addThis ios library.
I get the following error:
ld: duplicate symbol _OBJC_CLASS_$_Facebook in /Users/mars/Desktop/Pst/trunk/Pst/ThirdPartyLibs/FBConnect/FacebookSDK/FacebookSDK.framework/FacebookSDK(Facebook.o) and /Users/mars/Library/Developer/Xcode/DerivedData/Pst-bqmphjiqldalzsankfvxugsurcdj/Build/Intermediates/Pst.build/Debug-iphonesimulator/Pst.build/Objects-normal/i386/Facebook.o for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I've double checked with my Compile Resource, and only 1 facebook.m is present.
I've also put "-fno-objc-arc" in my compiler flags for those library files because they are built without ARC
Any help would be really appreciated!!
I've got the same error when followed the instruction to drag ThirdPartyLibs to my project. It had added both FBConnect and FacebookSDK to my project.
If you open the AddThisDemo project, which comes with the library, you will see that only FacebookSDK and DeprecatedHeaders were added (not entire FBConnect). I have recreated this structure in my project and that had solved my issue.
Hope that helps!
For anyone with this issue but these answers are not helping: if you created one custom class and called it Facebook.h/.m, just change its name and after it, no more linkage errors.
You have a #import "facebook.m" in one of your files where you should have put #import "facebook.h".

Conditionally linking for #autoreleasepool

When I try to run my application in the iOS 4.3 simulator (Xcode 4.2), I crash when I hit #autoreleasepool{}, with:
dyld: lazy symbol binding failed: Symbol not found: _objc_autoreleasePoolPush
I looked around, and I see the workaround is to add libarclite_iphoneos.a. There's a version of this for the simulator, too, as libarclite_iphonesimulator.a.
I need to add both libraries to my project to make it run on both the simulator and hardware. But whichever I build, it complains that the other library is for an unsupported architecture.
For example, building for simulator:
ld: warning: ignoring file /Developer-4.2/Platforms/iPhoneOS.platform/
Developer/usr/lib/arc/libarclite_iphoneos.a, missing required architecture
i386 in file
How do I fix both of these simultaneously? Or should I just stick with the old NSAutoreleasePool syntax for now?
After a trials like clean, clean folder, resetting iPhone Simulator and even a restart, I changed the IPHONE_DEPLYMENT_TARGET on the target build setting down from iOS 5.0 to iOS 4.2.
Worked.
You can use the Other Linker Flags build setting to link in the library, and specialize the value based on whether it's "Any iOS" or "Any iOS Simulator".
You can also merge the two static libraries to one universal library. Go to the Terminal and say
lipo -create -output /where/you/want/it/libarclite_universal.a /Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/arc/libarclite_iphoneos.a /Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/arc/libarclite_iphonesimulator.a
You can verify the resulting file by saying (in Terminal)
file /where/you/put/it/libarclite_universal.a
It should output:
libarclite_universal.a: Mach-O universal binary with 3 architectures
libarclite_universal.a (for architecture i386):current ar archive random library
libarclite_universal.a (for architecture armv6):current ar archive random library
libarclite_universal.a (for architecture armv7):current ar archive random library
Since this lib is linked statically, your final app wont grow because of the included sim library since only whatever is needed by your app will get linked into your final app.