Alan Cabrera
Alan Cabrera

Reputation: 732

Cannot import Firebase in CocoaPod

I'm creating a CocoaPod from which I'd like to import Firebase. I get the error:

"No such module 'Firebase'"

When I add import Firebase to a Swift file in my pod.

My CocoaPod Foo's pod spec file, Foo.podspec, contains:

s.dependency 'Firebase', '~> 3.6'

Upvotes: 2

Views: 946

Answers (2)

Adam Darton
Adam Darton

Reputation: 11

I recently ran into this same problem and the solution I settled on so that I could use firebase from inside both my development pod as well as apps using it was to setup the firebase sdk inside Xcode so that it can be found in the same way that a system framework is.

  1. Download the firebase sdk
  2. Move the frameworks you need into Xcode /Applications/Xcode.app/Contents/Developer/Library/Frameworks/
  3. Setup your pod spec so that it knows where the frameworks are as well as add a few required dependencies.

    # Specify what libraries this depends on.
    s.libraries = [
      'c++', # FirebaseAnalytics.
      'icucore', # FirebaseDatabase.
      'sqlite3', # FirebaseAnalytics.
      'z', # FirebaseAnalytics.
    ]
    
    # Specify what frameworks this depends on.
    s.frameworks = [
      'AddressBook', # FirebaseAnalytics.
      'AdSupport', # FirebaseAnalytics.
      'CFNetwork', # FirebaseDatabase.
      'SafariServices', # FirebaseAnalytics.
      'Security', # FirebaseAnalytics, FirebaseAuth, FirebaseDatabase.
      'StoreKit', # FirebaseAnalytics.
      'SystemConfiguration', # FirebaseAnalytics, FirebaseDatabase.
      'FirebaseAnalytics',
      'FirebaseInstanceID',
      'FirebaseCore',
      'FirebaseCoreDiagnostics',
      'FirebaseNanoPB',
      'GoogleToolboxForMac',
      'FirebaseAuth',
      'GTMSessionFetcher',
      'FirebaseDatabase'
    ]
    s.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/**' }
    
    # LDFLAGS required by Firebase dependencies.
    s.pod_target_xcconfig = {
      'OTHER_LDFLAGS' => '$(inherited) -ObjC',
    }
    

This example only uses firebase Analytics, Auth and Database but I'm sure other frameworks could be added as well. It isn't the best solution but it works for my situation.

Upvotes: 1

Jose Garcia
Jose Garcia

Reputation: 21

It seems there is a problem with the module mapping in the podspec made by Firebase for the latest version of their pod (see https://github.com/CocoaPods/CocoaPods/issues/6138).

I am currently working on a chat system based on Firebase that I have abstracted as a private CocoaPod. If I erase all traces of Firebase in my code/ podspec, all other Pods are imported flawlessly. I don't know that there is much we can do until this is fixed.

Cheers!

Upvotes: 2

Related Questions