xmtp/libxmtp-swift
Swift Package and Cocoapod that wraps an XCFramework emitted by the `bindings_ffi` crate in [libxmtp](https://github.com/xmtp/libxmtp)
Usage
NOTE: This package is NOT meant to be directly consumed by end users. Instead see xmtp-ios which depends upon this package.
Process for updating from a [libxmtp](https://github.com/xmtp/libxmtp) Swift Binding Release (work in progress!)
- From libxmtp repo, go to Action => Release Swift Bindings => Run workflow (select branch to release from)
- Verify success in libxmtp releases
- Create a new branch in the
libxmtp-swiftrepo - With
libxmtprepo andlibxmtp-swift(this repo) cloned locally in sibling directories, andlibxmtpchecked out to the correct release commit, run the script (this should updatelibxmtp-swift/Sourcesdirectory):
`` bindings_ffi/run_swift_local.sh ``
- Update
LibXMTP.podspecversion, and then points.sourceurl toLibXMTPSwiftFFI.zipfrom the libxmtp release you created (verify the podspec is correct using the commandpod spec lint LibXMTP.podspec) - Update
Package.swiftbinary target url to point to the sameLibXMTPSwiftFFI.zipfrom the step above - Update the
Package.swiftchecksum to the checksum from the from the libxmtp release you created - Create a PR and merge to
libxmtp-swiftmain branch - Tag your commit on main using the value of the
s.versionfrom theLibXMTP.podspecthat you bumped earlier in step 5. => This will also trigger the cocoapod publish (see deploy_to_cocoapods.yml for more details)
You should now be able to reference the Swift Package and Cocoapod from xmtp-ios using the format below.
For testing purposes
Reference in Package.swift:
...
.package(url: "https://github.com/xmtp/libxmtp-swift", from: "0.0.1-beta0")
...Reference in Podspec:
...
spec.dependency 'LibXMTP', '= 0.0.1-beta0'
...Diagram
┌────────────────────────────────────┬─────────────────────────────┬─────────────────────────────────┐
│ │ │ │
│ xmtp/libxmtp: Shared Rust Code │ xmtp/libxmtp-swift │ xmtp/xmtp-ios - iOS SDK │
│ - xmtp-networking │ - Git repo to host Swift │ - Existing iOS xmtp SDK │
│ - xmtp-proto │ Package │ - Consumes libxmtp-swift as │
│ | │ - Also contains Podspec │ a Cocoapod via spec.dependency │
│ ---> bindings_swift │ for LibXMTP pod │ │
│ │ ┌──────────────────────┐ │ │
│ ┌──────────┐ ┌───────────────┐ │ ┌─►│-Package.swift │ │ │
│ │xmtp-proto├────►│xmtp-networking│ │ │ │-LibXMTPRust.xcfra... │ │ ┌──────────────────┐ │
│ └──────────┘ └─────┬─────────┘ │ │ │-Sources/... │ │ │ XMTP.podspec │ │
│ │ │ │ │ - [Generated files] │ │ │ Package.swift │ │
│ ┌───────────────▼────┐ │ │ └─────────┬────────────┘ │ ┌──► - │ │
│ │libxmtp/ │ │ │ │ Swift Pkg │ │ │ import LibXMTP │ │
│ │ bindings_ffi │ │ │ └──────────────┼─┘ │ │ │
│ │ w/ uniffi │ │ │ Github url │ └────────┬─────────┘ │
│ └──────────┬─────────┘ │ ├────────┐ or Cocoapod │ │ │
│ │ │ │filecopy│ ├─────────────▼───────────────────┤
│ Output: │ │ ├────────┘ │xmtp/xmtp-react-native │
│ ┌────────────────▼─────────┐ │ │ │ - consumes xmtp/xmtp-ios │
│ │ LibXMTPRust.xcframework ├──────┼─┘ │ as a Cocoapod │
│ └──────────────────────────┘ │ │ │
│ │ │ │
└────────────────────────────────────┴─────────────────────────────┴─────────────────────────────────┘Package Metadata
Repository: xmtp/libxmtp-swift
Default branch: main
README: README.md