Skip to content
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

Release 1.2.1 does not build as a Swift Package #3063

Closed
rickpasetto opened this issue Jun 7, 2023 · 5 comments
Closed

Release 1.2.1 does not build as a Swift Package #3063

rickpasetto opened this issue Jun 7, 2023 · 5 comments
Labels
bug Generally incorrect behavior needs investigation

Comments

@rickpasetto
Copy link

Summary

I am unable to add apollo-ios release 1.2.1 as a swift package dependency. As SPM builds it, I get:

.../apollo-ios/Sources/ApolloTestSupport/TestMock.swift:2:29: error: module 'ApolloAPI' was not compiled for testing
@_exported @testable import ApolloAPI
           ~~~~~~~~~~       ^

I started trying to create a simple failing case, but it is easier just to clone the repo and run make -- symptom is the same.

Version

1.2.1

Steps to reproduce the behavior

07:08:27 ~/Documents$ git clone https://github.com/apollographql/apollo-ios.git
Cloning into 'apollo-ios'...
remote: Enumerating objects: 54411, done.
remote: Counting objects: 100% (2277/2277), done.
remote: Compressing objects: 100% (1073/1073), done.
remote: Total 54411 (delta 1397), reused 1844 (delta 1127), pack-reused 52134
Receiving objects: 100% (54411/54411), 159.11 MiB | 4.26 MiB/s, done.
Resolving deltas: 100% (32793/32793), done.
07:09:27 ~/Documents$ cd apollo-ios/
07:09:30 (main) ~/Documents/apollo-ios$ make
swift package clean
swift build -c release
Fetching https://github.com/stephencelis/SQLite.swift.git from cache
Fetching https://github.com/mattt/InflectorKit from cache
Fetching https://github.com/apple/swift-argument-parser.git from cache
Fetched https://github.com/mattt/InflectorKit (0.76s)
Fetching https://github.com/apple/swift-collections from cache
Fetched https://github.com/stephencelis/SQLite.swift.git (0.89s)
Fetched https://github.com/apple/swift-argument-parser.git (0.95s)
Fetched https://github.com/apple/swift-collections (0.90s)
Computing version for https://github.com/apple/swift-argument-parser.git
Computed https://github.com/apple/swift-argument-parser.git at 1.2.0 (0.60s)
Computing version for https://github.com/apple/swift-collections
Computed https://github.com/apple/swift-collections at 1.0.4 (0.59s)
Computing version for https://github.com/mattt/InflectorKit
Computed https://github.com/mattt/InflectorKit at 1.0.0 (0.54s)
Computing version for https://github.com/stephencelis/SQLite.swift.git
Computed https://github.com/stephencelis/SQLite.swift.git at 0.14.1 (0.57s)
Creating working copy for https://github.com/apple/swift-collections
Working copy of https://github.com/apple/swift-collections resolved at 1.0.4
Creating working copy for https://github.com/stephencelis/SQLite.swift.git
Working copy of https://github.com/stephencelis/SQLite.swift.git resolved at 0.14.1
Creating working copy for https://github.com/apple/swift-argument-parser.git
Working copy of https://github.com/apple/swift-argument-parser.git resolved at 1.2.0
Creating working copy for https://github.com/mattt/InflectorKit
Working copy of https://github.com/mattt/InflectorKit resolved at 1.0.0
warning: 'apollo-ios': found 1 file(s) which are unhandled; explicitly declare them as resources or exclude from the target
    /Users/rick.pasetto/Documents/apollo-ios/Sources/ApolloCodegenLib/Frontend/auto_rollup.sh
Building for production...
remark: Incremental compilation has been disabled: it is not compatible with whole module optimization
remark: Incremental compilation has been disabled: it is not compatible with whole module optimization
remark: Incremental compilation has been disabled: it is not compatible with whole module optimization
remark: Incremental compilation has been disabled: it is not compatible with whole module optimization
remark: Incremental compilation has been disabled: it is not compatible with whole module optimization
remark: Incremental compilation has been disabled: it is not compatible with whole module optimization
remark: Incremental compilation has been disabled: it is not compatible with whole module optimization
remark: Incremental compilation has been disabled: it is not compatible with whole module optimization
remark: Incremental compilation has been disabled: it is not compatible with whole module optimization
~/Documents/apollo-ios/Sources/ApolloTestSupport/TestMock.swift:2:29: error: module 'ApolloAPI' was not compiled for testing
@_exported @testable import ApolloAPI
           ~~~~~~~~~~       ^
           
[9/15] Linking libApollo-Dynamic.dylib
make: *** [build] Error 1

Logs

No response

Anything else?

Note: problem might have been introduced earlier than version 1.2.1

@rickpasetto rickpasetto added bug Generally incorrect behavior needs investigation labels Jun 7, 2023
@calvincestari
Copy link
Member

Hi @rickpasetto - the error is valid but it's not a practical issue, i.e.: there is no action for us to take here.

The target that is causing the build error is ApolloTestSupport which is, as the name says, test support. It is not meant to be compiled for release builds but there is no way for us to specify that in the package manifest.

It sounds like your root issue might be adding ApolloTestSupport to your non-test application targets. There are similar issues like this in #2933 and #2982.

@rickpasetto
Copy link
Author

@calvincestari thank you for the reply. Question, then: How do you recommend using ApolloTestSupport for Xcode Previews then? It's awfully convenient to use Apollo Mocks for forging data to show in Xcode Previews. Just wrapping the import ApolloTestSupport in #if DEBUG won't work or be sufficient, correct? Any hints? Thanks!

@calvincestari
Copy link
Member

Have you tried the selection set initializers that were reintroduced with 1.2.0? I think those should suffice to initialize models to pass into the previews. Do you need anything specific from ApolloTestSupport; it really is only the test mock code in there.

@rickpasetto
Copy link
Author

Ah, no, didn't know about that! I will give it a shot. Do you happen to have a link to a reference doc?

@calvincestari
Copy link
Member

The Output options documentation shows some sample JSON of how to configure it. We've got an issue still to sort out with the documentation though so you can't view that API reference for the selectionSetInitializers parameter in the online docs but the code is always the canonical reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Generally incorrect behavior needs investigation
Projects
None yet
Development

No branches or pull requests

2 participants