swift-system

1.3.0

Low-level system calls and types for Swift
apple/swift-system

What's New

1.3.0

2024-05-16T04:31:41Z

1.3.0 release

This release primarily addresses a number of platform support issues.

What's New

  • Support for visionOS
  • Support for musl libc

What's Changed

  • swift-system now requires Swift 5.8
  • The Collection conformance of the SystemString has been improved. This makes it compatible with the Swift 6.0 standard library, in which Array's replaceSubrange() has become stricter about the correctness of the Collection types it handles.
  • The cmake configuration now understands more spellings for Arm64, improving compatibility with Windows compilers.
  • Adapted two syscall wrappers to support unusual nullability annotations in Android's NDK 26. The package needs this to build against recent NDKs.

New Contributors

Full Changelog: 1.2.1...1.3.0

Swift System

Swift System provides idiomatic interfaces to system calls and low-level currency types. Our vision is for System to act as the single home for low-level system interfaces for all supported Swift platforms.

Multi-platform not Cross-platform

System is a multi-platform library, not a cross-platform one. It provides a separate set of APIs and behaviors on every supported platform, closely reflecting the underlying OS interfaces. A single import will pull in the native platform interfaces specific for the targeted OS.

Our immediate goal is to simplify building cross-platform libraries and applications such as SwiftNIO and SwiftPM. System does not eliminate the need for #if os() conditionals to implement cross-platform abstractions, but it does make it safer and more expressive to fill out the platform-specific parts.

Usage

import SystemPackage

let message: String = "Hello, world!" + "\n"
let path: FilePath = "/tmp/log"
let fd = try FileDescriptor.open(
  path, .writeOnly, options: [.append, .create], permissions: .ownerReadWrite)
try fd.closeAfter {
  _ = try fd.writeAll(message.utf8)
}

Adding SystemPackage as a Dependency

To use the SystemPackage library in a SwiftPM project, add the following line to the dependencies in your Package.swift file:

.package(url: "https://github.com/apple/swift-system", from: "1.3.0"),

Finally, include "SystemPackage" as a dependency for your executable target:

let package = Package(
    // name, platforms, products, etc.
    dependencies: [
        .package(url: "https://github.com/apple/swift-system", from: "1.3.0"),
        // other dependencies
    ],
    targets: [
        .target(name: "MyTarget", dependencies: [
            .product(name: "SystemPackage", package: "swift-system"),
        ]),
        // other targets
    ]
)

Source Stability

The Swift System package is source stable. The version numbers follow Semantic Versioning -- source breaking changes to public API can only land in a new major version.

Contributing

Before contributing, please read CONTRIBUTING.md.

LICENSE

See LICENSE for license information.

Description

  • Swift Tools 5.8.0
View More Packages from this Author

Dependencies

  • None
Last updated: Tue Oct 22 2024 09:12:51 GMT-0900 (Hawaii-Aleutian Daylight Time)