-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing required module 'FirebaseCore' in unit tests #10049
Comments
I found a few problems with this issue:
|
Off the top of my head, this might be due to the FirebaseCore module headers not being visible from your test target. You can check your search paths build settings to see if this is the case. Otherwise, if you could upload a test project that repros this issue, it would help us identify the root cause. |
hey @morganchen12 ! Yes, sure. It's a simple project. I'll also have a look on your suggestion (paths build settings). |
Thanks for the great repro @alexanderkhitev Add FirebaseAuth as a linker dependency to the test targets: |
Thank you. I have only one question. Unless in this case we do not receive errors like this one? |
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. |
Ok, I was able to work around this by adding It's not immediately clear to me what the best solution for us from a library vendor standpoint is. |
This tripped me off as well. I first had |
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 😊 |
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: My test has nothing to do with Firebase. |
@nesimtunc this is an unrelated issue. Make sure the |
@matkuznik you should not add the frameworks to the test target or you'll have duplicate class definitions. See this comment for a workaround: #10049 (comment) |
I had to switch to pods, with that the error has gone. Thank you @morganchen12 |
guys, I found really weird solution, here is a short story for a better context $(BUILT_PRODUCTS_DIR)/<MyApp>.app/<MyApp> it 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 |
Should I add EDIT:
and
in SwiftPackageManager.md. But I have not installed |
Thanks a lot for you suggestion. Could you help me with finding a path to the |
@matkuznik it should be in the Derived Data directory for your target. |
Thanks. I found a few. One is located in the There is also a env variable to this folder |
I found a different (better?) workaround. Under my test target build settings, Testing, Test Host 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" |
Hey @GlebCherkashyn ! I tried your solution. It works. I tried with Xcode Version 14.2 (14C18). 🤔 |
@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 |
@chawkinsnz-hnry This helped me a lot! |
@GlebCherkashyn @bennoland |
I tried this workaround, problem with UPD |
This solution also worked for me ;) |
This worked for me not sure why, we need to do this. |
I had all Firebase libraries linked to the test target under |
I'm not sure but I created a project one week ago. Then I added 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 |
@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. |
[REQUIRED] Step 1: Describe your environment
Swift Package Manager
(select one)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:
The text was updated successfully, but these errors were encountered: