-
Notifications
You must be signed in to change notification settings - Fork 734
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
ApolloTestSupport causes issue after upgrading from 1.0.7 to 1.1.2 #2982
Comments
I'm currently facing this issue as well. |
I have the same problem. Additionally, the error appears when I run the test target. |
duplicated of #2985 |
Reopening this as the original issue, no need to duplicate it elsewhere, and there might be others subscribed to notifications for this issue. |
This seems related to #2933. |
I'm so confused by this... Why would this cause an issue during archiving when the |
I don't necessarily think this ticket is identical to #2933, but note my comments in that ticket anyway. Maybe they will help you here as well. |
I have three different release configurations to switch the environment in my project: Release Development, Release Staging, and Release Production. I'm encountering the mentioned issue only in the Staging and Production configurations. Note: the issue is still present with version 1.2.0. |
Have you checked if any of your release builds / configurations directly or indirectly include any of Apollo's generated mock or test packages? 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_". |
@lorderster, I assume it's just the backend URL and auth that's changing between the configurations? I'm curious why it would work in one but not the others. |
Unfortunately, we are currently importing ApolloTestSupport to create mock responses for UITests when launching the app. We are aware that creating mocks outside of the test target is not the best approach and we are actively searching for an alternative solution to run UITests using mock responses without importing ApolloTestSupport into the main project target.
@calvincestari, yes, we use configurations combined with schemas. The schema defines the environment from a visual perspective. Then, we use configurations linked to each schema to define backend URLs, other endpoints in general, bundle identifier, app icon, and certificates/profiles. Me too, I don't understand why the archive is working fine using the configuration "Release Development", instead it fails with "Release Staging" and "Release Production". |
Have you tried the new selection set initializers? Do they not work for your use case? |
thank you @calvincestari for the suggestion. |
See my previous comments here and here. The issue is the configuration name |
Thanks, that seemed to resolve that issue! |
Does anyone have a link to a Swift forum topic or documentation that provides a bit more insight into why this is needed? |
https://forums.swift.org/t/update-spm-to-support-custom-configuration-names/43075 |
You do realize that I've already given you an answer to this question a month ago? |
Just as a note, since you should be aware of this: renaming the configuration this way will cause the Swift packages to compile in debug mode, even though your app itself may not compile in debug mode. This is something you obviously don't want for delivering apps in release mode. |
Thanks for that note. Yes I just renamed our |
I hadn't realized but thank you. |
Just a bit of an update this doesn't seem to fix the issue as it has come back a few times and takes me having to play around a bunch with removing testability on everything, cleaning derived data and build folder about 50 times for it to work. Then it will work for a bit when trying to use SwiftUI Previews then come back randomly. I've also added the ApolloAPI and ApolloTestSupport framework to the libraries for just the test target and still will show it when not even running tests. This apollo upgrade has become such a headache :( |
I'm sorry you're having such a painful experience @jostster. I think we're seeing that the TestMocks are causing a lot of headaches for people due to the Diamond Problem linking issues and SwiftUI preview code being built in the application targets. I'm hoping mergable libraries make this a bit easier in coming months, but I'm feeling more and more that TestMocks aren't the great solution I hoped they would be. Moving back to just enabled the generated initializers on your selection set models and using those for mocking is seeming to be a lot less error prone for most people. |
@AnthonyMDev Thank you for the response. So we aren't specifically using any TestMocks however, if we do not include the ApolloTestSupport in our test target libraries, we get errors when running tests in the |
Whoa what?? That is very unexpected... There is nothing in To be clear, what you are experiencing here is different from what this issue thread is about. It's also something that has not ever been reported before. @jostster Any way that you can provide me an example project with a reproduction of this? I'm not sure how to even start looking into this without a reproduction. |
@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. |
@AnthonyMDev @jostster If I had to guess when the error appeared:
Above it in the logs there was likely something like: Which is the diamond dependency issue we have seen come up in other issues that @AnthonyMDev mentioned. Especially if removing |
This should be fixed by #362 which will be released within the next week. If you are still experiencing this bug once that is released, please let us know! |
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo iOS usage and allow us to serve you better. |
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:
Error:
Module 'ApolloAPI' was not compiled for testing
The text was updated successfully, but these errors were encountered: