skiptools / skiptools/skip

docs: Clarify conditional compilation restrictions with an example

Open Beginner friendly
#343 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

documentation
Dominant language
Swift
Stars
3.2k
Forks
106
Avg merge
6d 13h
Merged PRs (30d)
1

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open the compiler directives section at https://skip.tools/docs/platformcustomization/#compiler-directives and review its existing warning about os(Android) and !os(Android). Add the issue's failing and recommended Swift examples, including the link to issue #342, then verify that the explanation clearly states what Skip does not understand and what the workaround changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.