swift-system

Swift System provides idiomatic interfaces to system calls and low-level currency types.

Github星跟蹤圖

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: "0.0.1"),

Because SystemPackage is under active development,
source-stability is only guaranteed within minor versions (e.g. between 0.0.3 and 0.0.4).
If you don't want potentially source-breaking package updates,
use this dependency specification instead:

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

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: "0.0.1"),
        // other dependencies
    ],
    targets: [
        .target(name: "MyTarget", dependencies: [
            .product(name: "SystemPackage", package: "swift-system"),
        ]),
        // other targets
    ]
)

主要指標

概覽
名稱與所有者apple/swift-system
主編程語言Swift
編程語言Swift (語言數: 4)
平台
許可證Apache License 2.0
所有者活动
創建於2020-09-25 00:14:13
推送於2025-04-19 17:28:32
最后一次提交
發布數15
最新版本名稱1.4.2 (發布於 )
第一版名稱0.0.1 (發布於 )
用户参与
星數1.2k
關注者數151
派生數110
提交數396
已啟用問題?
問題數43
打開的問題數20
拉請求數139
打開的拉請求數20
關閉的拉請求數22
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?