Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ jobs:
# Includes temporary downstream UniFFI callback vtable patch:
# https://github.com/mozilla/uniffi-rs/pull/2821
- name: Build the Swift project (with temporary UniFFI ASan workaround)
run: ./swift/build_swift.sh
run: cargo xtask swift build

- name: Upload Swift build artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
Expand Down Expand Up @@ -166,6 +166,11 @@ jobs:
- name: Checkout code
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3

- name: Set up Rust
uses: dtolnay/rust-toolchain@fa04a1451ff1842e2626ccb99004d0195b455a88 # master
with:
toolchain: 1.94.1
Comment thread
Dzejkop marked this conversation as resolved.

- name: Select Xcode ${{ matrix.xcode-version }}
uses: maxim-lobanov/setup-xcode@ed7a3b1fda3918c0306d1b724322adc0b8cc0a90 # v1.7.0
with:
Expand All @@ -178,7 +183,7 @@ jobs:
path: swift

- name: Run Swift foreign binding tests
run: ./swift/run_swift_tests.sh
run: cargo xtask swift test --skip-build

- name: Install SwiftLint
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release-swift-kotlin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

env:
# The feature flags with which the Android library is built.
# For iOS, this is set in the `build_swift.sh` file.
# Used by both the Kotlin and Swift xtasks.
WALLETKIT_CARGO_FEATURES: compress-zkeys,embed-zkeys,v3

jobs:
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
# Includes temporary downstream UniFFI callback vtable patch:
# https://github.com/mozilla/uniffi-rs/pull/2821
- name: Build the project (iOS, with temporary UniFFI ASan workaround)
run: ./swift/build_swift.sh
run: cargo xtask swift build

- name: Compress XCFramework binary
run: |
Expand Down Expand Up @@ -106,7 +106,7 @@ jobs:

# Prepare Package.swift
brew install swiftlint
./swift/archive_swift.sh --asset-url "$ASSET_URL" --checksum "$CHECKSUM" --release-version "$NEW_VERSION"
cargo xtask swift archive --asset-url "$ASSET_URL" --checksum "$CHECKSUM" --release-version "$NEW_VERSION"
cp Package.swift target-repo/

# Commit changes
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ Replace `VERSION` with the desired WalletKit version.

2. Sync Gradle.

## Local development (iOS/Swift)

On macOS with Xcode and the iOS Rust targets installed, build a local Swift
package with:

```bash
cargo xtask swift local
```

The package is written to `swift/local_build/walletkit-swift`. Build only the
bindings and XCFramework with `cargo xtask swift build`, or run the foreign
binding tests with `cargo xtask swift test`.

See [`swift/README.md`](swift/README.md) for package integration details.

## Local development (Android/Kotlin)

### Prerequisites
Expand Down
2 changes: 1 addition & 1 deletion nix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This directory contains the Nix devshells and helper scripts used to
cross-compile WalletKit for Android and wasm, both locally and in CI.
Swift/iOS builds intentionally continue to use their existing host Xcode setup.
Swift/iOS builds intentionally use the host Xcode setup through `cargo xtask swift`.

The flake provides **devshells, not packages**: the shells pin the Rust
toolchain (from `rust-toolchain.toml`), the Android NDK, nargo and every
Expand Down
2 changes: 1 addition & 1 deletion nix/docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ set -euo pipefail
# nix/docker.sh flake show
#
# Swift builds are not provided by the flake because they depend on macOS and
# the host Xcode configuration; use the existing Swift build flow instead.
# the host Xcode configuration; use `cargo xtask swift` on macOS instead.

cd "$(dirname "${BASH_SOURCE[0]}")/.."

Expand Down
41 changes: 25 additions & 16 deletions swift/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,65 @@

This folder contains Swift support files for WalletKit:

1. Script to cross-compile and build Swift bindings.
2. Script to build a Swift package for local development.
3. Foreign tests (XCTest suite) for Swift under `tests/`.
1. Swift Package Manager configuration.
2. Foreign tests (XCTest suite) under `tests/`.

Swift automation is implemented by the workspace xtask and requires macOS with
Xcode, the iOS Rust targets, and `nargo` v1.0.0-beta.11 installed.

## Building the Swift bindings

To build the Swift project for release/distribution:
Run from anywhere in the workspace:

```bash
# run from the walletkit directory
./swift/build_swift.sh
cargo xtask swift build
```

This cross-compiles WalletKit, generates the UniFFI Swift bindings, and creates
`swift/WalletKit.xcframework`.

## Testing WalletKit locally

To build a Swift package that can be imported locally via Swift Package Manager:
Build a package that can be imported locally through Swift Package Manager:

```bash
# run from the walletkit directory
./swift/local_swift.sh
cargo xtask swift local
```

This creates a complete Swift package in `swift/local_build/` that you can import in your iOS project.
The complete package is created at `swift/local_build/walletkit-swift`.

## Integration via Package.swift

Add the local package to your Package.swift dependencies:
Add the local package to your `Package.swift` dependencies:

```swift
dependencies: [
.package(name: "WalletKit", path: "../../../walletkit/swift/local_build"),
.package(name: "WalletKit", path: "../../../walletkit/swift/local_build/walletkit-swift"),
// ... other dependencies
],
```

Then add it to specific targets that need WalletKit functionality:
Then add it to the targets that need WalletKit:

```swift
.target(
name: "YourTarget",
dependencies: [
.product(name: "WalletKit", package: "WalletKit"),
// ... other dependencies
]
],
),
```

## Running foreign tests for Swift

```bash
# run from the walletkit directory
./swift/test_swift.sh
cargo xtask swift test
```

The command builds the bindings and runs the test suite on an available iPhone
simulator. To test artifacts built separately, as CI does, run:

```bash
cargo xtask swift test --skip-build
```
78 changes: 0 additions & 78 deletions swift/archive_swift.sh

This file was deleted.

Loading
Loading