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

docs: Clarify conditional compilation restrictions with an example #343

Open
dfabulich opened this issue Feb 17, 2025 · 0 comments
Open
Labels
documentation Improvements or additions to documentation

Comments

@dfabulich
Copy link

dfabulich commented Feb 17, 2025

https://skip.tools/docs/platformcustomization/#compiler-directives includes this warning:

Because the Skip tooling does not know the value of any symbols other than os(Android) and !os(Android), we strongly recommend adding os(Android) or !os(Android) conditions to all #if blocks, so that it is clear whether Skip should include or exclude the code for Android.

That line made no sense at all to me when I read it.

What it means to say is that #if !os(macOS) won't work, which is filed as #342. You have to rewrite it as #if !os(macOS) || os(Android).

The documentation would be much clearer with an example of issue #342 and the recommended workaround.

For example, this won't work, because Skip doesn't understand the symbol os(macOS), or its negation !os(macOS).

Text("Hello World")
    #if !os(macOS)
    // BUG this won't run on Android
    .italic()
    #endif

Instead, use an "unnecessary" os(Android):

Text("Hello World")
    #if !os(macOS) || os(Android)
    .italic()
    #endif

We hope to address this issue in a future version of Skip.

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

No branches or pull requests

2 participants