The Noosphere Swift workspace contains source code for Swift bindings to Noosphere.
./swift/Sources/SwiftNoosphere/
: Bindings between the C FFI and Swift../swift/Tests/SwiftNoosphereTests/NoosphereTests.swift
: Tests for the Swift module
The Noosphere Swift module binds to the Noosphere binary, built from rust. All Noosphere build dependencies must be installed as a part of the Swift module build process.
Only macOS is supported.
- Noosphere rust toolchain
- Xcode
xcode-select --install
Swift modules linking to binaries must link to an XCFramework, an artifact containing one or several binaries for multiple platforms.
- Generate headers for the Noosphere library (
noosphere.h
) - Generate static libraries for target architectures (e.g.
aarch64-apple-darwin/release/libnoosphere.a
) - Generate universal binaries using lipo from the static libraries
- Generate multiplatform framework bundle from the universal binaries (
LibNoosphere.xcframework
)
Running ./scripts/build-framework.sh
will generate headers, static libraries for appropriate architectures, and combine them into a universal binary. To generate a framework only including the host platform (either x86_64-apple-darwin or aarch64-apple-darwin), from the project root, run:
./scripts/build-framework.sh --lite
A framework should be created at ./target/framework/debug/LibNoosphere.xcframework
.
Generating a multiplatform framework (including universal binaries for macOS, iOS simulator, and aarch64-apple-ios) requires building for 5 different platforms so may take some time. For a multiplatform framework, we probably want to use release optimizations, so also set --release
. From the project root, run:
./scripts/build-framework.sh --release
After building the framework, swift tests can be run via:
./scripts/swift-test.sh
If wanting to target the release framework, be sure to use --release
:
./scripts/swift-test.sh --release
The script temporarily rewrites the Package.swift
in the project root with the local XCFramework for local development and testing.