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

Failed SwiftUI preview on macOS #341

Closed
honghaoz opened this issue Nov 25, 2022 · 1 comment · Fixed by #389
Closed

Failed SwiftUI preview on macOS #341

honghaoz opened this issue Nov 25, 2022 · 1 comment · Fixed by #389

Comments

@honghaoz
Copy link
Contributor

honghaoz commented Nov 25, 2022

Hi!

I'm hitting an issue that the macOS target fails for SwiftUI previews. I understand this package doesn't support macOS, but it does create issues on macOS.

My situation is:
I have a Swift package that supports both iOS and macOS platforms.

The package uses

.package(url: "https://github.com/devicekit/DeviceKit", from: "5.0.0"),

in dependencies.

I set the target dependency for iOS platform only:

.product(name: "DeviceKit", package: "DeviceKit", condition: .when(platforms: [.iOS])),

Using the DeviceKit package on macOS target has no issues for normal build.

However, when using SwiftUI preview on macOS target, it always fails. The problem is somehow the SwiftUI preview builds the DeviceKit source code for macOS platform:

CleanShot 2022-11-24 at 21 12 51@2x

I think the fix is straightforward, we should wrap the whole generated code under:

#if os(iOS) || os(watchOS) || os(tvOS)

#endif

This problem happens on the latest Xcode (14.1 (14B47b))

@honghaoz
Copy link
Contributor Author

Made a PR: #342

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant