y-crdt / yswift

Swift language bindings to Y-CRDT
https://y-crdt.github.io/yswift/documentation/yswift/
Other
68 stars 6 forks source link

macOS xcframework - cross platform enablement and some other cleanup #18

Closed heckj closed 1 year ago

heckj commented 1 year ago

resolves #6

I moved back to including the generated header and swift files from uniffi-bindgen since they need to be in lock-stop, but are used in two (potentially) different release steps down the road. The core issue with the XCFramework I encounted earlier was a admittedly arcane precondition that the modulemap file in an XCFramework must be named module.modulemap, and I'd incorrectly assumed that anything matching *.modulemap would do the trick. Turns out - nope. With that sorted, the generation is fewer files by quite a bit, although it takes longer now as well, since we're generating all of iOS, iOS simulator, and macOS platform support within the single XCFramework.

The relevant binary sizes for macOS:

4.6M Feb 11 13:25 target/x86_64-apple-darwin/release/libuniffi_yniffi.a
4.6M Feb 11 13:25 target/aarch64-apple-darwin/release/libuniffi_yniffi.a

combined macOS using lipo:

9.2M Feb 11 13:25 target/apple-darwin/release/libuniffi_yniffi.a

iOS:

8.8M Feb 11 13:25 target/aarch64-apple-ios/release/libuniffi_yniffi.a

iOS Simulator:

4.8M Feb 11 13:24 target/x86_64-apple-ios/release/libuniffi_yniffi.a
8.8M Feb 11 13:24 target/aarch64-apple-ios-sim/release/libuniffi_yniffi.a

And combined architectures for the simulator:

14M Feb 11 13:25 target/ios-simulator/release/libuniffi_yniffi.a

Total generated XCFramework size:

nugmanoff commented 1 year ago

Amazing job!!! You really did crack the xcframeworks thing. May I leave here an article with your learnings from your blog – I think it's very well-written article on the nitty-gritties details of under-documented xcframeworks space, and it could serve as a great reference into your thought process for anyone who comes by this PR/changes.

Thanks for taming and soundproofing this quite flaky process🙏🏻

heckj commented 1 year ago

I also submitted a PR to uniffi-rs to update their docs with this little hard-to-find detail: https://github.com/mozilla/uniffi-rs/pull/1473