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

SwiftUI Previews not working #16

Open
jbromberg opened this issue Jan 18, 2024 · 8 comments
Open

SwiftUI Previews not working #16

jbromberg opened this issue Jan 18, 2024 · 8 comments

Comments

@jbromberg
Copy link

SwiftUI Previews fail to load when using this package due to many compile errors related to the ProcessEnv and FSEventsWrapper dependencies. Here's a build log showing the errors:

Build for Previews code-edit_2024-01-18T10-57-02.txt

@mattmassicotte
Copy link
Contributor

Ahhh you are building for the simulator. I wonder if that’s it.

@jbromberg
Copy link
Author

Yea no matter what I change the device to in the SwiftUI preview window I get the same errors

@mattmassicotte
Copy link
Contributor

Really appreciate the report!

There are checks in there, and they appear good enough for Linux builds. Need to investigate.

@mattmassicotte
Copy link
Contributor

Could it be that according to SPM this is macOS, but according to the compiler it is not? That would be a wild problem that I would totally believe.

@mattmassicotte
Copy link
Contributor

I have confirmed that in this specific situation, the package dependency conditionals think this is macOS 😵‍💫.

@jbromberg
Copy link
Author

Hmmm. So does that mean using @available wouldn't work?

@mattmassicotte
Copy link
Contributor

@available is a good thought, but that is a runtime construct, not a compile-time thing. We need to prevent the compiler from seeing this code. (This distinction is a little confusing. I wrote about it a bit here: https://www.chimehq.com/blog/swift-and-old-sdks)

Step one, I managed to create a reasonably minimal example and included it in a bug report: FB13551706

@mattmassicotte
Copy link
Contributor

mattmassicotte commented Jan 23, 2024

So I investigated a few different possible fixes for this, and I wasn't able to find one that didn't have drawbacks.

I think the most readable solution, given that this only affects SwiftUI previews on iOS is to maintain a branch with the features not supportable by iOS explicitly removed.

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

No branches or pull requests

2 participants