Open sourcing SwiftSystem?

Apple has introduced a new SwiftSystem overlay library as part of its 2020 OSes, which converts system calls and other APIs to better Swift types, like a native FileDescriptor type. @tkremenek et al, is there any intention to open source this library, like Swift Crypto, so the overlay can become cross platform? This would be huge for Swift on other OSes.


It seems to only include file descriptors, paths and errors, and everything maps exactly to C. Strange that it isn’t part of Foundation.

Although, if they don’t open source it, it would be nice if it didn’t have a completely generic name.

Strong +1 on this, the amount of low-level libraries one needs to be aware of when developing a cross-platform package is growing, and this complicates things significantly. Here's something that a cross-platform Swift developer needs to do currently:

#if canImport(Darwin)
import Darwin
#elseif canImport(Glibc)
import Glibc
#elseif canImport(MSVCRT)
import MSVCRT
#elseif canImport(WASI)
import WASI

And more will be added in the future, for example I think it would make sense to support something like import Musl to enable some Linux distributions such as Alpine. Having a unified module that irons out these small differences would help tremendously.

It also has Filepath.withCString(_:) which is better then using FileManager.fileSystemRepresentation(withPath:) in swift-corelibs-foundation since it wont have to leak the string.

One of the WWDC talks mentioned that libswiftCore was now below Foundation on macOS so it would make it easier for writing libraries in Swift that dont want to use Foundation at all.


One potential issue is the POSIX-ness. The errno values don't make sense on Windows. If we are to have a virtual file system library under, we need to think about its abstractions a little further.


I saw that and was embarrassed to learn that Foundation and the Swift Standard Library are not the same thing.

Yes, we want to make this open source and also available on Linux by the end of Swift 5.3.

System itself won't be a cross-platform abstraction (e.g., it will have differences for the different system calls on the different platforms).

Windows support probably won't be there initially because of the larger differences with Windows that will take more time to implement, but it can all be developed in open source — especially once Windows support for Swift officially arrives.

Terms of Service

Privacy Policy

Cookie Policy