Question about platform specific API

Hi, Swift beginner here,
I was scavenging around the Swift docs for something short of a type that would be good to use to encapsulate paths.
I found Apple Developer Documentation, but I am not sure if the specific types n stuff on the page are iOS/iPadOS/macOS specific, or if these are also available on Linux (what I currently use to develop in Swift)
If the latter, I'm not sure how to import them...
Thanks in advance.

1 Like

import System. - Swift System is Now Open Source

1 Like

If the path in question is a file path, then there is Foundation.URL and Swift System as linked to by tera above. Depending on your use case, some things listed on this documentation page might help too, especially Foundation.FileManager. If the path is a web URL path, then the WebURL package by @Karl provides the best solution (and as far as I know the only correct solution).

In general, everything in the Swift and PackageDescription modules should be available on Linux, but be careful that some computed properties, static properties, functions, etc (i.e. things that can be defined in an extension from outside of the module) on the documentation are defined in extensions in Apple's closed-source libraries/frameworks. Most things in Foundation, Dispatch, and XCTest should be available on Linux. For what's not available in Foundation, this documentation might help. The open-source implementations of Dispatch and XCTest are hosted here and here, but they don't seem to contain information on their differences from Apple's closed-source implementations.

The difficulty you've experienced in finding useful information is yet another case highlighting the need for Swift's documentation to be hosted for all open-source Swift users, and separate from Apple's closed-source libraries/frameworks that use Swift. Hopefully this is something the website workgroup and/or the documentation workgroup are actively working on.