Why won’t swift-hash build on the Swift Package Index?

I phrased that in past tense, because it no longer works very reliably. Since the changes to shared state and caching, the list of quirky ways to break the workaround keeps growing. For example, if Xcode is open and you try xcodebuild, parts of the build will borrow the (wrong) environment from Xcode instead of inheriting from the terminal session.

If you want to try anyway, some third party packages and development tools have already informally standardized on the Boolean environment flags TARGETING_MACOS, TARGETING_WINDOWS, TARGETING_WEB, TARGETING_UBUNTU, TARGETING_TVOS, TARGETING_IOS, TARGETING_ANDROID, TARGETING_AMAZON_LINUX and TARGETING_WATCHOS. See here for an example of it in use.

I have considered bringing it up around before, but it always felt like every use case was really just an indication of a bug that should be fixed instead, and that drawing attention to workarounds would just reduce the incentive to fix the bugs.

1 Like