Apollo-ios: SwiftUI Preview Fails

Created on 25 Feb 2020  路  8Comments  路  Source: apollographql/apollo-ios

I think I've followed the installation instructions on the docs page, https://www.apollographql.com/docs/ios/installation/, and my builds works and runs on the similar just fine, but my swiftui preview breaks with this error in the diagnostics. I'm new to swiftui (though fairly familiar with Apollo/graphql from other projects) and searching didn't find similar issue.

apollo-ios -> 0.23.0
Xcode -> 11.3.1

use of unresolved identifier \'Process\'

----------------------------------------

SchemeBuildError: Failed to build the scheme "practice"

use of unresolved identifier 'Process'

Compile /Users/peck/Library/Developer/Xcode/DerivedData/practice-ffshylstkbdpuwdygwokyrmihofw/SourcePackages/checkouts/apollo-ios/Sources/ApolloCodegenLib/Basher.swift:
/Users/peck/Library/Developer/Xcode/DerivedData/practice-ffshylstkbdpuwdygwokyrmihofw/SourcePackages/checkouts/apollo-ios/Sources/ApolloCodegenLib/Basher.swift:27:16: error: use of unresolved identifier 'Process'
    let task = Process()
               ^~~~~~~

On apollo-ios 0.22.0 I don't see the issue and preview seems to generally work as expected

build-issue

Most helpful comment

Actual fix shipping with 0.23.2 courtesy @TizianoCoroneo

All 8 comments

Hi! What package manager are you using? Can you validate that the ApolloCodegenLib is not included in the libraries that are being added to your iOS application? It's designed to only be used with MacOS, though it seems like I should probably add some defensive if statements around that.

@peck The defensive @available statements have shipped with 0.23.1 which should prevent compilation of any of the classes that aren't available on iOS. I'm gonna close this out, please reopen if you're still seeing this issue when using 0.23.1. Thank you!

Apologies for not seeing your first reply, didn鈥檛 get a notification from github for that one.

I鈥檒l give the new version a try and see if it fixes it.

To answer the question, I鈥檓 using swift package manager and did not have codegen lib included.

Thanks!

Following up, I tried with the latest release and get the same error

image

There is a very real possibility that I did something wrong to get here, and I don't have quite enough experience with the swift ecosystem yet to be of much help on tracking down the core issue, but Im still seeing it. Maybe best to keep the issue closed and if others have it can be revisited?

馃憢 I got the same error using 0.23.0, and still in 0.23.1. Downgrading to 0.22.0 fixed the issue for me as well - SwiftUI preview is working again

What the...oy. Yeah 0.22.0 doesn't have the ApolloCodegenLib at all so it would definitely not have this problem.

Reopening - can you please take a look at the Build Phases for the target you're running SwiftUI with and make sure you do not have the ApolloCodegenLib in either your Link Binary With Libraries phase or your Embed Frameworks phase?

I had setup Apollo with SwiftPM, and I'm importing it as a dependency for another local package, so there is no Build phase to look at 馃槄 About the target I'm using, it doesn't attempt to link ApolloCodegenLib or embed its framework; but I've found a different fix and opened a PR.
https://github.com/apollographql/apollo-ios/pull/1066

Actual fix shipping with 0.23.2 courtesy @TizianoCoroneo

Was this page helpful?
0 / 5 - 0 ratings