firebase-ios-sdk: Missing required module 'FirebaseCore' in unit tests
[REQUIRED] Step 1: Describe your environment
- Xcode version: 14.0 beta 4 (14A5284g)
- Firebase SDK version: 9.3.0
- Installation method:
Swift Package Manager(select one) - Firebase Component: FirebaseAuth, FirebaseAnalyticsSwift, FirebaseAuthCombine
- Target platform(s):
iOS
[REQUIRED] Step 2: Describe the problem
Steps to reproduce:
I added three SDKs for now in one of my pet project and it works but when I try to launch unit tests (XCTestCase) I get error “Missing required module ‘FirebaseCore’” where @testable import AppName is declared. Do we have any solutions for this? Thanks.
Relevant Code:

About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 13
- Comments: 31 (8 by maintainers)
@bennoland’s suggestion worked a trick for my project using SPM and Xcode 14.2(14c18).
I also tried making a fresh empty project in Xcode with Firebase as the sole SPM dependency and hit the same problem where tests would fail to build as soon as the host app’s code imported Firebase. Following @bennoland’s suggestion this fixed it here too
guys, I found really weird solution, here is a short story for a better context I have xcode project with multiple targets, and I have one test bundle for each target to test snapshots. We’ve added 2 more targets about 6 months ago, I did it, and I added 2 new test bundles, so it’s kinda “fresh” in my memory. And now we have to add another one, but I couldn’t do that due to
Missing required moduleissue. I’ve tried multiple ways, like switching to pods/SPM, linking binaries for test bundle… But I’ve noticed one thing:Bundle Loadersetting inBuild settingshad two slashes (see screenshot). When I manually changed value toit worked!
This is definitely xcode 14 issue, because when you change a host for test bundle, it puts two slashes again!
I really hope that will help you, I’ve spent 3-4 days searching a solution
Thanks for the great repro @alexanderkhitev
Add FirebaseAuth as a linker dependency to the test targets:
I found a different (better?) workaround.
Under my test target build settings, Testing, Test Host Change it from: “$(BUILT_PRODUCTS_DIR)/MyApp.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/MyApp” to: “$(BUILT_PRODUCTS_DIR)/MyApp.app/MyApp”
The BUNDLE_EXECUTABLE_FOLDER_PATH variable was evaluating to empty, so I was seeing a double slash in the path “$(BUILT_PRODUCTS_DIR)/MyApp.app//MyApp”
Yes, same here with @matkuznik
Adding libs to test target is not a problem, however running tests are crashed due random errors from Firebase. For example:
-[FBLPromise HTTPBody]: unrecognized selector sent to instanceMy test has nothing to do with Firebase.
Could someone explain why we have to add Firebase* to the tests targets? I have 5 others frameworks which do not have to be added 🤔.
Thanks 😊
Thank you SOOOO MUCH !
@chawkinsnz-hnry This helped me a lot! These steps should be included in the https://github.com/firebase/firebase-ios-sdk/blob/master/SwiftPackageManager.md
Good question. I see that also. It seems that Xcode is using different search path algorithms between compiling and linking, but I’m not sure why.
@CarlitosDroid you won’t see the issue unless the modules are actually required in your tests I think.
I’ve updated the SPM readme’s known issues section to sort issues by most replies, so this will be at the top. Thanks all for posting your workarounds.
I’m not sure but I created a project one week ago. Then I added
FirebaseFirestore,AlamofireandKingfisherdependencies fromSwift Package Manager.When I try to run unit tests. I’ve got this error:
As @NfoDkt mentioned above. I can see the two double slashes.
However, I’ve just created a new project with the same dependencies and now I don’t have any issue:
XCode Version
I had all Firebase libraries linked to the test target under
Link binary with librarieswhich resulted in slow test builds and 3 out of 4 test runs failing with-[FBLPromise HTTPBody]: unrecognized selector sent to instance. Removing the linked libraries and setting the test host appropriately instead seems to have fixed the issue.@matkuznik it should be in the Derived Data directory for your target.
This tripped me off as well. I first had
Missing required module 'FirebaseFirestore'. After including this as described by @paulb777 I got errors aboutAppCheckso now I just ended up linking all possible firebase libraries to the test target, which got it working. Have to say that this issue was pretty hard to find, so maybe including some hints in the SPM README would be a good idea.Ok, I was able to work around this by adding
-Xcc -fmodule-map-file="/path/to/FirebaseCore.modulemap"in the test targets’Other Swift Flagsbuild setting. What’s going on is explained via @Neonichu here.It’s not immediately clear to me what the best solution for us from a library vendor standpoint is.
Thank you. I have only one question. Unless in this case we do not receive errors like this one? Class FIRCoreDiagnosticsLog is implemented in both