- Swift 44.1%
- Rust 28.1%
- C 15.1%
- Makefile 12.7%
- xcframework Headers dir was missing module.modulemap → consumer 'import CStallariYRS' fails. Stage headers + modulemap in build/staged-headers/ before xcodebuild -create-xcframework. - xcodebuild emits Info.plist AvailableLibraries in non-deterministic order. Post-process with python3 plistlib to sort by LibraryIdentifier. - New SHA-256: 1d5f14c250d0db606a9c8607729a4d1fcb88c545ba68e86d176fc05987a6e8e5 - New tag: 0.1.1 (0.1.0 retained per never-delete rule; harness pins 0.1.1). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> |
||
|---|---|---|
| rust | ||
| Sources | ||
| Tests/StallariYRSTests | ||
| .gitignore | ||
| CLAUDE.md | ||
| Makefile | ||
| Package.swift | ||
| README.md | ||
| rust-toolchain.toml | ||
stallari-yrs
Swift Package Manager library wrapping the yrs Rust CRDT library via C FFI. Provides YDocument, YText, YAwareness for collaborative document editing in Stallari.
Build
Requires Rust toolchain with Apple targets (pinned via rust-toolchain.toml):
rustup target add aarch64-apple-darwin aarch64-apple-ios
cargo install cbindgen
Local development build (rebuilds the Rust static lib + Swift wrapper from source):
make build # macOS arm64 only
make universal # macOS + iOS arm64
make release-xcframework # production: deterministic xcframework + SHA-256 (DD-295 Phase C)
Run tests:
make test
Binary distribution
Per DD-295 Phase C amendment § "Binary-distributed siblings", consumers of this package resolve CStallariYRS as a SwiftPM binaryTarget(url:, checksum:) pointing at the stallari_yrs.xcframework.zip asset attached to each tagged GH Release on groupthink-dev/stallari-yrs. The published xcframework bundles both macos-arm64 and ios-arm64 static-library variants built with cargo build --release --locked against the pinned Rust toolchain. make release-xcframework builds the asset; make verify-xcframework validates determinism (two consecutive builds must produce identical SHA-256). Release assets are append-only — never deleted, never re-uploaded with --clobber — to preserve swift package resolve for any historical consumer commit.
Architecture
rust/src/lib.rs → C FFI bridge (#[no_mangle] pub extern "C")
Sources/CStallariYRS/ → C module (module.modulemap + yrs_ffi.h) — input to xcframework build
Sources/StallariYRS/ → Swift wrappers (YDocument, YText, YAwareness)
lib/ → Compiled static libraries (git-ignored, populated by `make build`)
build/ → xcframework + zip output (git-ignored, populated by `make release-xcframework`)
Memory Management
Every yrs_*_new has a corresponding yrs_*_free. Swift classes call free in deinit. Buffers returned by FFI functions must be freed with yrs_buf_free or yrs_string_free.
YDocument is @unchecked Sendable — yrs uses internal RwLock. Callers should serialise write access via an actor (PadEngine in stallari-harness).