Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello @designatednerd 👋
Thank you for your amazing work on this library! I had the same issue reported here and decided to try to help out.
This PR fixes an issue that started with the inclusion of
ApolloCodegenLib
in0.23.0
, where all SwiftUI previews for files in targets that also import Apollo stopped working with the following error:In my case, I have Apollo as a dependency using SPM. I don't know if this issue is reproducible with cocoapods or other dependency managers.
This happens because
ApolloCodegenLib
is meant to be built only on macOS, and this check is only enforced with a runtime@available
annotation instead of a compile-time#if os(macOS)
.I looked for a way to specify a specific platform per-target directly in the SPM manifest, but according to this PR in the SPM repo there is no way for now (and he recommends to strip away the platform specific code using
#if
):This PR applies the suggestion specified above. I'm sorry it is not below 20 lines and I'm not really following the contributor guide, but this seems an "innocuous" bug fix. 😄
I don't know how to test this behavior with SwiftUI previews to be honest.