LibXMTP Swift

Swift 包和 Cocoapod,它包装了 libxmtpbindings_ffi crate 发出的 XCFramework

用法

注意:此包不供最终用户直接使用。 请参阅依赖于此包的 xmtp-ios

libxmtp Swift Binding Release 更新的流程(正在进行中!)

  1. libxmtp 仓库,转到 Action => Release Swift Bindings => Run workflow(选择要从中发布的branch)
  2. libxmtp releases 中验证成功
  3. libxmtp-swift 仓库中创建一个新 branch
  4. libxmtp 仓库和 libxmtp-swift(此仓库)克隆到本地兄弟目录中,并将 libxmtp 检出到正确的 release commit,运行脚本(这应该会更新 libxmtp-swift/Sources 目录)
    bindings_ffi/run_swift_local.sh
    
  5. 更新 LibXMTP.podspec 版本,然后将 s.source url 指向您创建的 libxmtp release 中的 LibXMTPSwiftFFI.zip(使用命令 pod spec lint LibXMTP.podspec 验证 podspec 是否正确)
  6. 更新 Package.swift 二进制目标 url,使其指向上述步骤中的相同 LibXMTPSwiftFFI.zip
  7. Package.swift 校验和更新为您创建的 libxmtp release 中的校验和
  8. 创建一个 PR 并合并到 libxmtp-swift main branch
  9. 使用您在第 5 步中提升的 LibXMTP.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                   │
│  └──────────────────────────┘      │                             │                                 │
│                                    │                             │                                 │
└────────────────────────────────────┴─────────────────────────────┴─────────────────────────────────┘