Firebase-ios-sdk: No such module "Firebase" in Swift Tests (Add explicit Firebase modulemap)

Created on 2 Jun 2017  路  13Comments  路  Source: firebase/firebase-ios-sdk

[READ] Step 1: Are you in the right place?

Yes

[REQUIRED] Step 2: Describe your environment

  • Xcode version: Any
  • Firebase SDK version: 4.0.0
  • Library version: 4.0.0
  • Firebase Product: All (auth, database, storage, core, messaging, etc)

[REQUIRED] Step 3: Describe the problem

Swift unit tests fail to find Firebase module. During the distribution process, the Firebase podspec relies on Core to set up proper header search paths using user_target_xcconfig. Firebase should have its own modulemap instead of relying on the header search paths from Core.

Steps to reproduce:

  1. Create a Swift project with unit tests
  2. pod init to create a Podfile
  3. Add pod 'Firebase' to Podfile under use_frameworks!
  4. Run pod update
  5. Open the generated xcworkspace
  6. Add import Firebase to the AppDelegate.swift
  7. Add @testable import <YourProjectName> into <YourProjectName>Tests.swift
  8. A "No such module 'Firebase'" error will appear.

Relevant Code:

Currently generated podspec

Relevant Issues:

Swift unit tests fail to find Firebase module
Swift Cocoapod can't import Firebase pod dependencies
Unable to run tests (quickstarts)

Workarounds:

  • Add "${PODS_ROOT}/Firebase/Core/Sources" to your Tests target only under Build Settings -> Header Search Paths
core

Most helpful comment

Update:

All 13 comments

Is this not a duplicate of #16? Turns out it's not

Any progress on this?

Btw the workaround does not work for me.
CocoaPods notes that I am using these versions.

Using Firebase (3.17.0)
Using FirebaseAnalytics (3.9.0)
Using FirebaseAuth (3.1.1)
Using FirebaseCore (3.6.0)
Using FirebaseDatabase (3.1.2)
Using FirebaseInstanceID (1.0.10)
Using FirebaseMessaging (1.2.3)
Using FirebaseRemoteConfig (1.3.4)

I am not using Firebase 4.x but I assume this is not fixed yet?

@zapjonny The issue has not yet been fixed, but if the workaround does not work for you, there is likely another issue with your configuration. Please create another issue with enough detail to reproduce the problem.

Before the below I manually installed the Firebase iOS SDK (upgrading to 4+), and I was able to work around the problem that way too.

Then I read your reply, and yes I just started unit testing as late as yesterday and probably failed my setup. Apparently we need to add our unit test targets as a target in the podfile too (unless I got that wrong too). Anyway as soon as I did that I didn't have any problems running my unit tests. Running latest 4.x something of Firebase now.

And as far as I know, I am not using the suggested workaround from above but my unit tests still work. Maybe I did something different during setup.

FIY it is not failing just the tests, i have a swift framework using firebase and i cannot use it at the moment because firebase fails to import, still looking for a workaround

@tirrorex You're running into a different issue: There is currently no clean way for frameworks to depend on Firebase. See https://github.com/CocoaPods/CocoaPods/issues/5368

i am already following this issue :/
Good to know this is separate but...

Update:

I've probably a related problem. I've a xcode project with multiple targets. They all use Firebase and the same set of other pods. It' all looks ok, but I can only run one (sort of random after install) of the targets. Switching between targets, cleaning and building will fail on the 'No such module Firebase'

I've tried the work arround, but that doesn't seem to work either.

after do pod update then no such module firebase ? how to resolve this error ?

This issue is fixed with CocoaPods 1.4.0. For earlier CocoaPods releases, please use the workaround describe here.

If neither solution is working for you, please create another issue with full information about your configuration.

Was this page helpful?
0 / 5 - 0 ratings