Swift Package and Cocoapod that wraps an XCFramework emitted by the bindings_ffi
crate in libxmtp
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 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-swift
repo - With
libxmtp
repo andlibxmtp-swift
(this repo) cloned locally in sibling directories, andlibxmtp
checked out to the correct release commit, run the script (this should updatelibxmtp-swift/Sources
directory):bindings_ffi/run_swift_local.sh
- Update
LibXMTP.podspec
version, and then points.source
url toLibXMTPSwiftFFI.zip
from the libxmtp release you created (verify the podspec is correct using the commandpod spec lint LibXMTP.podspec
) - Update
Package.swift
binary target url to point to the sameLibXMTPSwiftFFI.zip
from the step above - Update the
Package.swift
checksum to the checksum from the from the libxmtp release you created - Create a PR and merge to
libxmtp-swift
main branch - Tag your commit on main using the value of the
s.version
from theLibXMTP.podspec
that 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.
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'
...
┌────────────────────────────────────┬─────────────────────────────┬─────────────────────────────────┐
│ │ │ │
│ 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 │
│ └──────────────────────────┘ │ │ │
│ │ │ │
└────────────────────────────────────┴─────────────────────────────┴─────────────────────────────────┘