apollo-ios: ApolloTestSupport causes issue after upgrading from 1.0.7 to 1.1.2
Summary
Using Swift Package Manager, after updating from 1.0.7 to 1.1.2, the import of ApolloTestSupport causes the archive process failure. The build process is still working.
Version
1.1.2
Steps to reproduce the behavior Import ApolloTestSupport in any file, and the following code from TestMock.swift will generate an error:
#if !COCOAPODS
@_exported @testable import ApolloAPI
@testable import Apollo
#endif
Error: Module 'ApolloAPI' was not compiled for testing
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 6
- Comments: 28 (10 by maintainers)
Have you checked if any of your release builds / configurations directly or indirectly include any of Apollo’s generated mock or test packages? If that is the case, that is one reason why this leads to said error. This also includes
ApolloTestSupport
which may not be imported into any of your release builds.So the first step I can recommend you is to make sure that no Apollo test packages are imported or used for your release builds.
The other case I described is when you use test builds with a different configuration that is not called “Debug” or whose name does not start with “Debug_”.
@AnthonyMDev I don’t have a test project, however, I did go in and check our linking and removed our generated Apollo API library from our test target. This allowed our tests to pass without erroring out on the JSONRequest.
I hadn’t realized but thank you.
Thanks for that note. Yes I just renamed our
Testing
toDebug_Testing
https://forums.swift.org/t/update-spm-to-support-custom-configuration-names/43075
thank you @calvincestari for the suggestion. The issue is resolved with the new selection set initializers, as we no longer need to import ApolloTestSupport in the main app target.
I’m so confused by this… Why would this cause an issue during archiving when the
TestMocks
are in a test support target. This target should not even be being built for archive builds. @calvincestari lets get on a call and chat about this one soon.