48

I am using firebase as part of a project I am working on in iOS, and I just stumbled upon the following linking error when I try to compile my code against an iPhone 6 or 7 simulator for testing.

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_GTMSessionUploadFetcher", referenced from:
      objc-class-ref in FirebaseStorage(FIRStorageUploadTask_d5061b1e2b5f1bb249816cc5fc42ff62.o)
  "_OBJC_CLASS_$_GTMLogger", referenced from:
      objc-class-ref in FirebaseMessaging(GIPReachability_ae5504e4a6a28a1d8997c6f38e8bff8b.o)
  "_kGTMSessionUploadFetcherStandardChunkSize", referenced from:
      -[FIRStorageUploadTask enqueue] in FirebaseStorage(FIRStorageUploadTask_d5061b1e2b5f1bb249816cc5fc42ff62.o)
  "_GTMFetcherStandardUserAgentString", referenced from:
      -[FIRAuthBackendRPCIssuerImplementation init] in FirebaseAuth(FIRAuthBackend_ea73237c278bd1b78e1c76db2a16775a.o)
  "_OBJC_CLASS_$_GTMSessionFetcher", referenced from:
      objc-class-ref in FirebaseStorage(FIRStorageDownloadTask_c390366e83519f6636ca985ecb70e5d0.o)
      objc-class-ref in FirebaseStorage(FIRStorage_691ea9ac7cb4d224d37df2ff8a911989.o)
  "_OBJC_CLASS_$_GTMSessionFetcherService", referenced from:
      objc-class-ref in FirebaseAuth(FIRAuthBackend_ea73237c278bd1b78e1c76db2a16775a.o)
      objc-class-ref in FirebaseStorage(FIRStorage_691ea9ac7cb4d224d37df2ff8a911989.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 am using Xcode 8.2.1, swift 3.0, and I also have the following Pod file in my project

pod 'Braintree'
pod 'Firebase/Auth'
pod 'Firebase/Database'
pod 'Firebase/Core'
pod 'Firebase/Storage'
pod 'Firebase/Messaging'
pod 'Firebase/RemoteConfig'
pod 'GeoFire', :git=>'https://github.com/firebase/geofire-objc.git'
pod 'ObjectMapper', '~> 2.2'

I have done a pod update in case something was out of date, but no luck. The code compiles and runs fine when I use an iPhone 4 or 5 simulator.

Edit:

I have set Build Active architectures to No, in valid architectures I have listed arm64, armv7, armv7s and now Objectmapper is failing even though import ObjectMapper is declared in the file

 Use of undeclared type 'Mappable'

Any help would be greatly appreciated! Thank you in advance.

George.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
gdev
  • 601
  • 1
  • 5
  • 10
  • 1
    In XCode mark `Build Setting > Build Active Architectures only > YES` – Sachin Vas Feb 17 '17 at 07:44
  • Hi Sachin, thank you for the suggestion, but unfortunately this setting is already in YES – gdev Feb 17 '17 at 07:46
  • 2
    Sorry, it should be `NO`. – Sachin Vas Feb 17 '17 at 08:15
  • I just, tried it but now I get more errors similar to the ones I was getting before – gdev Feb 17 '17 at 08:31
  • I think my issue is that I had arm64 under my valid architectures. I did not place it there myself, I just noticed that existed. Now that I removed it its compiling. I hope I did not mess anything else up by removing this – gdev Feb 17 '17 at 08:55
  • You won't be able to compile the code for the devices then. arm64 is a device architecture. – Sachin Vas Feb 17 '17 at 10:33
  • You have a point, but what is the solution then?, because I am not able to compile otherwise. armv7 is listed under device architectures. Is that the same? – gdev Feb 17 '17 at 12:20
  • Yes, don't remove it. Use the latest version of the `ObjectMapper`. Why are you constraining it to 2.2 – Sachin Vas Feb 17 '17 at 13:55
  • I did what you suggested, I removed the constraint on ObjectMapper and run a pod update but same thing happens. What I notice is that when I switch the Build Active Architectures to YES, the Firebase errors return, the ObjectMapper errors go away and visa versa. Very strange.. @Frank Any suggestions? – gdev Feb 17 '17 at 15:15
  • FWIW, I had a project with mix of frameworks and pods. I moved everything to pods and fixed the build issues. – Adam Mendoza Dec 01 '19 at 16:20

20 Answers20

56

Just discovered a similar problem and got it solved by clearing Pod-Cache.

Clear CocoaPods Cache

pod deintegrate && pod cache clean --all

Re-Install Pods

pod install

coyer
  • 4,122
  • 3
  • 28
  • 35
28

For me I just installed Firebase framework to Xcode, not using CocoaPods due to other unsolvable issues. After build there is similar errors like above with "symbol(s) not found for architecture x86_64". (maybe because I am working with Xcode on VMWare)

Then I have to manually go to General - Linked Frameworks and Libraries and add:

libsqlite3.tbd, libz.tbd, libc++.tbd

for the project to work.

Quan Nguyen
  • 5,074
  • 3
  • 24
  • 26
  • I only needed to add `libsqlite3.tbd` – Joshua Nov 09 '17 at 15:15
  • 5
    For me it was libsqlite3.tdb, libc++.tbd, StoreKit.framework – Josh Sep 21 '18 at 06:21
  • 1
    `libsqlite3.tbd`, `libz.tbd`, `libc++.tbd`, `StoreKit.framework` for me as of Firebase v5.16.0. – raurora Jan 23 '19 at 23:05
  • I also had to do the -ObjC entry in Build Settings / Other Linker Flags – self.name May 25 '19 at 04:54
  • 2
    Adding these linked libraries should not be necessary, according to the Firebase README. These librares are used by one or more of the Firebase frameworks. What worked for me was to create a bridging header, add "#import Firebase.h" to it, and reference it in Build Settings > Objective-C Bridging Header. – Mike Taverne Oct 28 '19 at 18:29
  • For Xcode 11 and above, Build Phases -> Link Binar With Libraries – Shebin Koshy Apr 24 '20 at 22:03
12

It seems to be a glitch with derived data. I quitted out of Xcode, I removed all Derived Data in /Users/USER_NAME/Library/Developer/Xcode/PROJECT_NAME

Restarted Xcode, compiled and all works as expected, no need to change anything in Active Architecture Only or anything.

Pang
  • 9,564
  • 146
  • 81
  • 122
gdev
  • 601
  • 1
  • 5
  • 10
12

I tried the "clearing Cocoapods cache" and the "removing derived data" solutions but that didn't work. What worked for me was a step I found in the Carthage setup (I'm still using Cocoapods)

Add $(OTHER_LDFLAGS) -ObjC flag to "Other Linker Flags" in "Build Settings".

You can see the step here: https://github.com/firebase/firebase-ios-sdk/blob/master/Carthage.md

My Info

Installation: Cocoapods | SDK: FirebaseAnalytics (6.1.2) | IDE: Xcode 11.0 | macOS: Mojave 10.14.5 Beta | Language: Swift 4.2 | Platform Target: iOS 11.0+

Kilo Loco
  • 529
  • 5
  • 10
12

Also had this problem after installing pods for Firebase, using CocoaPods as explained in the Firebase site:

https://firebase.google.com/docs/ios/setup?hl=es-419#prerequisites

pod 'Firebase/Analytics' pod 'Firebase/Auth'

During the installation of the pods I received a warning telling that:

[!] The target `myTarget [Debug]` overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Pods.xcconfig'.
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

[!] The target `myTarget [Release]` overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Pods.xcconfig'.
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

When I compiled I got the error for several files:

Undefined symbols for architecture x86_64:

I tried the solution of the following answer before the one in this answer, and it worked as a charm:

The target ... overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Pods.xcconfig

Basically the solution was (as explained by @Ankish Jain):

Go to your Target Build Settings -> Other linker flags -> double click -> + button. Add $(inherited) to a new line.

After that I compiled succesfully, and new flag where added automatically to the Build Settings.

L33MUR
  • 4,002
  • 2
  • 12
  • 27
  • 1
    Thank you so much! I also got those warnings when installing Firebase pod but just ignored it and was struggling to make the Analytics work. As a not iOS developer, none of the other answers made sense to me. – Limpuls Jan 20 '21 at 13:16
  • 1
    Don't forget to remove the derived data & clean the project after doing this. – Ahmadreza May 28 '21 at 04:05
8

Also had this issue...
Added $(inherited) to other linker flags in build settings and everything works fine now

Mark Kazakov
  • 946
  • 12
  • 17
5

I tried the solutions in this question, and nothing worked. Also found other threads in SO and GitHub issues. Nothing helped. I am using Xcode 9.2, Swift 4, latest version of cocoa pods. This worked for me...

First, my podfile only contains one firebase pod since I am only using Analytics at this point, however solution approach should be the same if you're using more.
pod 'Firebase/Core'

Second, like documentation states, make sure -ObjC is added to your Other Linker Flags. I did this both at project and target level build settings. They were different.

Third and most important, at Project level build settings, Other Linker Flags, add the following

-framework

"FirebaseCore"

-framework

"FirebaseAnalytics"

-framework

"FirebaseInstanceID"

-framework

"FirebaseNanoPB"

-framework

"FirebaseCoreDiagnostics"

-framework

"nanopb"

Augie
  • 1,341
  • 1
  • 11
  • 18
5

I had the same problem following the steps of integrating without CocoaPods (https://firebase.google.com/docs/ios/setup#frameworks) and none of the other answers helped me.

What worked for me was removing -ObjC from Other Linker Flags on the target's Build Settings.

I am still not sure why that worked even though it is explicit written on the steps to add this flag, just wanted to share what worked for me in the attempt of maybe helping someone else.

Luca Schifino
  • 61
  • 1
  • 1
  • +1 this worked for me. Tested in Xcode 11 and 12 beta, imported with Cocoapods. This also fixed a similar error I was getting with the AppCenter pod. – Jon Willis Sep 09 '20 at 15:08
3

Had the same problem, and for me the issue was that I had imported the FirebaseMessaging framework manually, by downloading the entire Firebase SDK and then manually importing the Messaging framework into the project (I didn't use Cocoapods or Carthage). I didn't import the other framework in the same folder, "Protobuf.framework". Once adding Protobuf and making sure the target memberships included my project target, it worked.

COSMO BAKER
  • 337
  • 4
  • 16
2

I encountered this issue before, It looks like you need to:

rm -rf ios/Podfile ios/Podfile.lock ios/Pods ios/Runner.xcworkspace

and then run flutter run

Source: https://github.com/flutter/flutter/issues/41900

UPDATE: run this fix the issue too: rm -f ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings

Ryan
  • 800
  • 1
  • 13
  • 27
2

If nothing is working for you then try downgrading firebase pods. I downgraded it to '6.27.0' and it worked like a charm. I read this solution here.

pod 'Firebase/Core', '6.27.0'
Shunan
  • 3,165
  • 6
  • 28
  • 48
2

I got the same error when I integrated Firebase manually without using CocoaPod and built for simulator. (There is no problem just for device build.)

This is old question, but it's related, so I show my recent solution.

First, I gave up building for only simulator.

It takes too long time for building, but I set "Build Active Architecture Only" to "No" to build all the targets including simulator.

Also I added "Any iOS Simulator SDK - arm64" in "Excluded Architectures" in Build Settings, because my Mac OS architecture is not "arm64" but "x86_64".

If necessary, you should add "Any iOS Simulator SDK - i386" too. Firebase contains "i386" architectures, but some other Ad SDK doesn't support "i386" any more.

That's my acceptable solution.

deve
  • 71
  • 5
  • I found that sometimes even this solution doesn't work. If you cannot link to x86_64 frameworks, you should delete "bin" and "build" folder in your project and then build again. That will work. – deve Nov 27 '20 at 08:07
1

In my case everything worked after removing $(inherited) from Other Linker Flags

Booharin
  • 753
  • 10
  • 10
1

Check your Other linker flags: sometimes adding or removing $(inherited) solves the issue.

Andrew Morton
  • 24,203
  • 9
  • 60
  • 84
JimBim
  • 23
  • 5
1

I have tried all advices but only this one worked !!! My error was this after installing firebase pod :

Undefined symbols for architecture x86_64
error: linker command failed with exit code 1 (use -v to see invocation)

And here is the only solution worked for me:

pod deintegrate && pod cache clean --all

rm -rf ~/Library/Developer/Xcode/DerivedData

then add the below version of Firebase to your pod file

pod 'Firebase', '6.27.0'

and then

pod install
smoothumut
  • 3,423
  • 1
  • 25
  • 35
0

For me the issue was that xCode has a bug when I would drag in new frameworks it wouldn't set the target membership properly.

Expand all folders and go to your .framework files or .m files that you just dragged in before this started happening, highlight each one, press cmd+option+1 and make sure the target membership box is checked and set to required: enter image description here

Albert Renshaw
  • 17,282
  • 18
  • 107
  • 195
0

In my case, for using only Firebase Auth and Firebase Firestore, installing with Cocoapods, all I had to do was click the + sign for both Debug and Release sections under Other Linker Flags in Build Settings. The $(inherited) flag was added automatically. Built just fine after that!

Screenshot

G Wayne
  • 51
  • 2
0

Tried most of the suggestions in the other answers here, but none fixed it. What ultimately fixed it was adding the following to the top of Podfile:

$RNFirebaseAsStaticFramework = true

This is part of the instructions here, but I must have missed it: https://rnfirebase.io/#altering-cocoapods-to-use-frameworks

Daniel Chesher
  • 328
  • 1
  • 2
  • 5
0

I created a pod that has a dependency to the firebase analytics pod, when I ran into this issue.

To solve the problem I needed to add the following line in the pod spec file:

s.static_framework = true

Then a complete spec file should be similar to this

Pod::Spec.new do |s|
package = JSON.parse(File.read(File.join(File.dirname(__FILE__), 'package.json')))

s.name = 'NameOfMyGreatPod'
s.version = package['version']
s.summary = package['description']
s.license = package['license']
s.homepage = package['homepage']
s.author = package['author']
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
s.ios.deployment_target  = '13.0'
s.static_framework = true
s.dependency 'Capacitor'
s.dependency 'Firebase/Analytics'

end

0

I got this error message after copying a project from one MacBook to another. In order to solve the problem I had to remove the Swift Package Manager dependency and then reinstall it. Screenshot below to show flow for removing a package.

To reinstall: Follow the instructions in the Firebase documentation: https://firebase.google.com/docs/ios/installation-methods

Flow for removing package dependency

Eric Duffett
  • 1,654
  • 17
  • 25