Skip to content

Latest commit

 

History

History

swift

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Noosphere Swift

License Tests

The Noosphere Swift workspace contains source code for Swift bindings to Noosphere.

⚠️ The Noosphere Swift module mostly contains raw bindings to the underlying FFI. Higher-level Swift interfaces will eventually migrate from Subconscious into the module directly over time. ⚠️

Environment Setup

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.

Building

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

Testing

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.