-
Notifications
You must be signed in to change notification settings - Fork 743
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
Apollo 1.1.0 @testable import in Test Mocks compilation error #2933
Comments
Hmmm interesting! Thanks for the report. How are you including Apollo? Are you using SPM in an Xcode Project, or is your project defined with a |
Thanks for quick response and sorry I forgot to mention, I use SPM, directly via packages dependencies under project settings |
Thanks for the info! I'll look into how to correct this and get back to you ASAP |
@SzymonMatysik I'm not able to reproduce this in a unit test target. Are you accidentally linking |
This was fixed in #2937. |
@AnthonyMDev You were right about accidentally linking ApolloTestSupport into main app target, nevertheless when I deleted it and added into UnitTest target only the issue persists. I've checked on 1.1.2, still with no luck |
@SzymonMatysik are there no other warnings or errors in the build log? Are you able to replicate this in a separate project that could be shared with us? |
@calvincestari I'm trying to get working reproducible project case but as far without luck - everything works on new project. On the other hand I got some insights on big project - I am able to compile and run the app with success but the Unit Tests got same error as mentioned above. In this project we got some modules, for example networking layer and models layer, each layer imports Apollo or ApolloAPI and I import those modules into tests as @testable import. Maybe I'm doing something wrong here? |
In our case, we were using Mocks into our internal build release. Looks like we can't release this target anymore because of the |
We've got the same issue and it is not solved with #2937 The reason in our case is that Apollo is a transient dependency of another Swift package (a dependency of a dependency).
|
This is a good pointer in the right direction - thank you! @SzymonMatysik, @Tulleb - is there anything similar in the way you're linking to the Apollo library? |
@calvincestari what's the reason this issue was closed? It seems I've found one cause for the issue: Switching to the Debug configuration gets rid of the build error but is not really an option for us since we need a separate build configuration for tests. I can also reproduce this 100%, when I switch back to the testing configuration, the error occurs again: I have also tried it by simply cloning the debug configuration and thus using an identical configuration with a different name. This alone is enough for this error to occur. |
The root cause of the problem seems to be this: When a Swift package is compiled there are only two configurations that are used: Debug or Release. If a configuration name is unknown, Release is used as a fallback. So if you use a different build configuration in Xcode, it seems the Apollo targets are all built with a release configuration. Which should ultimately lead to the described problem. |
And to leave a solution here that might help others: |
It was closed because it was believed to have been fixed - #2933 (comment). @testable is not usable in anything other than Debug builds. or those specifically marked for 'testing'; Release builds violate both of those and it seems there are some deficiencies in SPM that allows for custom build configurations that would resolve this. It looks like we can probably remove To be frank, with the introduction of selection set initializers in
I haven't tried this myself but thank you for sharing this to help others that might be facing the same issue. |
Just to be clear, our testing configuration was not a release configuration, but a debug configuration. The problem of the SPM arose solely from the configuration name. That |
Summary
While compiling project I've expected issue with ApolloAPI in TestMock.swift, second line:
Module 'ApolloAPI' was not compiled for testing
.Dropping to 1.0.7 erases the issue.
I've tried on Xcode 14.2 and 14.3 - same results.
Version
1.1.0
Steps to reproduce the behavior
Upgrade Apollo from 1.0.7 to 1.1.0 and try to compile.
Logs
Anything else?
The text was updated successfully, but these errors were encountered: