swift-system icon indicating copy to clipboard operation
swift-system copied to clipboard

Add support for visionOS

Open noahpistilli opened this issue 1 year ago • 2 comments

Adds compilation support for visionOS. All tests pass. Closes #150.

I was unsure if I had to edit Utilities/expand-availability.py, so I didn't touch it.

noahpistilli avatar Feb 20 '24 04:02 noahpistilli

I would prefer to do this by setting a compilation variable in the package manifest. This os||os||os||os||os list was already unwieldy, and it's only getting worse.

glessard avatar Feb 23 '24 18:02 glessard

Perhaps something like

swiftSettings: [
      .define("APPLE", .when(platforms: [Platform.macOS, Platform.iOS, Platform.watchOS, Platform.tvOS, Platform.visionOS])),

in the package manifest?

noahpistilli avatar Feb 27 '24 19:02 noahpistilli

Perhaps something like


swiftSettings: [

      .define("APPLE", .when(platforms: [Platform.macOS, Platform.iOS, Platform.watchOS, Platform.tvOS, Platform.visionOS])),

in the package manifest?

If you do go this route, note that Apple has non Darwin uses of Swift such as the triple: armv7em-apple-none-macho.

You could name this define DARWIN instead?

rauhul avatar Feb 27 '24 21:02 rauhul

@swift-ci please test

glessard avatar Mar 05 '24 22:03 glessard

The testing failure involves a change in Swift 6.0. Will need to fix this separately.

glessard avatar Mar 05 '24 23:03 glessard

@noahpistilli I think the approach is good, but the symbol "DARWIN" may be a bit too prone to collisions, given that it could possibly be passed from the command-line by any package that uses this. May I suggest something less likely have collisions, such as "SYSTEM_PACKAGE_DARWIN"?

glessard avatar Mar 08 '24 01:03 glessard

@swift-ci please test

glessard avatar Mar 08 '24 05:03 glessard

Wouldn't it be better to use canImport(Darwin)?

Especially since a lot of these are literally guarding imports of the Darwin module and uses of symbols exported by it...

karwa avatar Mar 08 '24 17:03 karwa

Wouldn't it be better to use canImport(Darwin)?

Especially since a lot of these are literally guarding imports of the Darwin module and uses of symbols exported by it...

This seems abundantly obvious now that you say it...

rauhul avatar Mar 08 '24 17:03 rauhul

@swift-ci please test

glessard avatar Mar 08 '24 21:03 glessard

#if canImport() has a namespacing issue; nothing particular prevents a Linux distribution from having a module named Darwin. We've avoided using that approach for that reason. It would be nicer to be able to check specifically for the thing we need, and to be honest in this package Darwin isn't it.

glessard avatar Mar 08 '24 21:03 glessard

#if canImport() has a namespacing issue; nothing particular prevents a Linux distribution from having a module named Darwin. We've avoided using that approach for that reason.

It’s only an issue if this package were to introduce a dependency on another package named “Darwin”, or if a third-party toolchain were to include a Swift module named “Darwin” in its standard installation.

That’s sufficiently unlikely that I don’t think it needs to be a concern. Such a toolchain would quickly encounter widespread problems across the Swift ecosystem and would likely choose a different name.

Importantly, the official toolchain would not encounter issues when building for Apple platforms. That’s the only thing I think we need to be concerned about right now.

karwa avatar Mar 08 '24 21:03 karwa