Swift 包和 Cocoapod,它包装了 libxmtp 中 bindings_ffi
crate 发出的 XCFramework
注意:此包不供最终用户直接使用。 请参阅依赖于此包的 xmtp-ios。
libxmtp-swift
仓库中创建一个新 branchlibxmtp
仓库和 libxmtp-swift
(此仓库)克隆到本地兄弟目录中,并将 libxmtp
检出到正确的 release commit,运行脚本(这应该会更新 libxmtp-swift/Sources
目录)bindings_ffi/run_swift_local.sh
LibXMTP.podspec
版本,然后将 s.source
url 指向您创建的 libxmtp release 中的 LibXMTPSwiftFFI.zip
(使用命令 pod spec lint LibXMTP.podspec
验证 podspec 是否正确)Package.swift
二进制目标 url,使其指向上述步骤中的相同 LibXMTPSwiftFFI.zip
Package.swift
校验和更新为您创建的 libxmtp release 中的校验和libxmtp-swift
main branchLibXMTP.podspec
中的 s.version
值标记您在 main 上的 commit。 => 这也将触发 cocoapod 发布(有关更多详细信息,请参阅 deploy_to_cocoapods.yml)现在您应该可以使用以下格式从 xmtp-ios 引用 Swift Package 和 Cocoapod。
在 Package.swift 中引用
...
.package(url: "https://github.com/xmtp/libxmtp-swift", from: "0.0.1-beta0")
...
在 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 │
│ └──────────────────────────┘ │ │ │
│ │ │ │
└────────────────────────────────────┴─────────────────────────────┴─────────────────────────────────┘