Skip to content

Commit

Permalink
scaffolding
Browse files Browse the repository at this point in the history
  • Loading branch information
mkobetic committed Jul 31, 2023
1 parent d1b8165 commit 296a9da
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// swift-tools-version:5.3
import PackageDescription
import Foundation

let package = Package(
name: "LibXMTP",
platforms: [
.iOS(.v13),
.macOS(.v11)
],
products: [
.library(
name: "LibXMTP",
targets: ["LibXMTP", "LibXMTPRust"]),
],
targets: [
.target(
name: "LibXMTP",
dependencies: ["LibXMTPRust"],
path: "Sources/LibXMTP"
),
.binaryTarget(
name: "LibXMTPRust",
path: "LibXMTPRust.xcframework")
]
)
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# 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](https://github.com/xmtp/xmtp-ios) which depends upon this package.


### 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 │
│ └──────────────────────────┘ │ │ │
│ │ │ │
└────────────────────────────────────┴─────────────────────────────┴─────────────────────────────────┘
```
17 changes: 17 additions & 0 deletions XMTPRust.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Pod::Spec.new do |s|
s.name = 'LibXMTP'
s.version = '0.0.1-beta0'
s.summary = 'XMTP shared Rust code that powers cross-platform SDKs'

s.homepage = 'https://github.com/xmtp/libxmtp-swift'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'XMTP Labs' => '[email protected]' }
s.source = { :git => 'https://github.com/xmtp/libxmtp-swift.git', :tag => s.version.to_s }

s.platform = :ios, '13.0', :macos, '11.0'
s.swift_version = '5.3'

s.vendored_frameworks = 'LibXMTPRust.xcframework'

s.source_files = 'Sources/LibXMTP/**/*'
end

0 comments on commit 296a9da

Please sign in to comment.