Undefined symbol: _OBJC_CLASS_$_FIRApp
Asked Answered
R

5

8

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

enter image description here

And screenshot of added dependency

enter image description here

Rundlet answered 11/11, 2020 at 12:32 Comment(10)
Swift dependency package is swift package manager?Hierodule
yes using swift package managerRundlet
Does this manual not work github.com/firebase/firebase-ios-sdk/blob/master/…?Hierodule
nope i tried... m not sure but maybe my project is so old because of that facing this issue..but i don't know how to solvedRundlet
To old project should use cocoapods instead of SPMHierodule
Please provide Package.swift fileHierodule
same i tried using cocoa but in cocoa pod i m not able to import firebase in my APPdelegate so after that m using swift package managerRundlet
Just @import Firebase;Hierodule
safenote.co/r/5fabf1a57e4a77@32263035 here is link of Package of swift fileRundlet
No luck using @import firebaseRundlet
R
15

After so much searched I solved issue. Solution is

  1. "$(inherited)" In Other Linker Flags
  2. Build Active Architecture Only value to "Yes"
  3. Add Run Script for firebase SPM is "${BUILD_DIR%Build/*}SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run"
  4. Clean project
  5. Build Project
Rundlet answered 7/1, 2021 at 4:30 Comment(3)
what will be script in case of pod not SPMSexuality
Doesn't "Build Active Architecture Only value to "Yes"" build only for the architecture of the machine you are building on? What happens when you build for a physical phone or to send to the app store?Faltboat
Adding $(inherited) in Other Linker Flags works for me. Thank you.Areopagus
K
3

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.

Kyle answered 4/2, 2022 at 6:21 Comment(3)
For me, only this solution worked. On which older iOS devices would work? The accepted solution didn't work. Also, did you find anything, later on, that would make it work on older devices too?Stallard
It wont work on older devices since they support only 32 bit but it wont affect much as almost all the devices supported by Apple now are 64 bit.Kyle
Thanks! However, when I did these changes, I got a different error: FBLPromises.h file not found It is coming under GoogleUtilities_EnvironmentStallard
L
1

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

Loralorain answered 9/5, 2022 at 8:52 Comment(0)
C
0

Can try this it Will help,

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

Screenshot

Counterclockwise answered 30/1, 2022 at 18:12 Comment(1)
I noticed that this answer has received some downvotes, but the point made is actually correct and important. If Firebase is encapsulated within a module (e.g., a Telemetry module), you might encounter an Undefined symbol error if the Mach-O Type setting isn't configured properly. Specifically, ensure that the Mach-O Type is set to Dynamic Library. I have personally reproduced this issue, so it's worth double-checking this setting if you're integrating Firebase within a module.Cathryncathy
A
-1

I had to update my OS and xcode to the latest version for it to work.

Advocation answered 11/5, 2023 at 14:41 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.