Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
229 changes: 229 additions & 0 deletions .github/workflows/arkdrop-swift-bindings-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
name: ARK Drop Swift Bindings Release

on:
push:
paths:
- "drop-core/entities/**"
- "drop-core/exchanges/**"
- "drop-core/uniffi/**"
- ".github/workflows/arkdrop-swift-bindings-release.yml"
workflow_dispatch:

jobs:
build-and-publish:
runs-on: macos-latest
permissions:
contents: write
packages: write

steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-apple-ios,x86_64-apple-ios,aarch64-apple-ios-sim,x86_64-apple-darwin,aarch64-apple-darwin

- name: Verify Rust targets
run: |
rustup target list --installed
echo "Verifying targets are installed..."
for target in aarch64-apple-ios x86_64-apple-ios aarch64-apple-ios-sim x86_64-apple-darwin aarch64-apple-darwin; do
if rustup target list --installed | grep -q "$target"; then
echo "✓ $target is installed"
else
echo "✗ $target is NOT installed"
rustup target add "$target"
fi
done

- uses: Swatinem/rust-cache@v2
with:
workspaces: drop-core/uniffi

- name: Install Xcode Command Line Tools
run: |
xcode-select --install 2>/dev/null || true
xcode-select -p

- name: Generate Swift Bindings
working-directory: ./drop-core/uniffi/bindings/swift
run: |
chmod +x generate-bindings.sh
./generate-bindings.sh
env:
RUST_BACKTRACE: 1

- name: Verify Generated Bindings
working-directory: ./drop-core/uniffi/bindings/swift
run: |
echo "Checking generated files..."
ls -la
echo ""
echo "Required files check:"
for file in ArkDrop.swift arkdrop_uniffiFFI.h module.modulemap; do
if [ -f "$file" ]; then
echo "✓ $file exists"
echo " Size: $(wc -c < "$file") bytes"
else
echo "✗ $file missing!"
exit 1
fi
done

- name: Build XCFramework
working-directory: ./drop-core/uniffi/bindings/swift
run: |
chmod +x build-xcframework.sh
./build-xcframework.sh
env:
RUST_BACKTRACE: 1

- name: Create Swift Package Archive
working-directory: ./drop-core/uniffi/bindings/swift
run: |
echo "Creating distributable Swift package..."

# Create package directory structure
mkdir -p ArkDrop-Swift-Package
mkdir -p ArkDrop-Swift-Package/Sources/ArkDrop

# Verify all required files exist before copying
echo "Verifying files before packaging..."
for file in arkdrop_uniffiFFI.xcframework ArkDrop.swift Package.swift arkdrop_uniffiFFI.h module.modulemap; do
if [ ! -e "$file" ]; then
echo "ERROR: Required file missing: $file"
exit 1
fi
done

# Copy XCFramework
echo "Copying XCFramework..."
cp -r arkdrop_uniffiFFI.xcframework ArkDrop-Swift-Package/

# Copy Swift source to Sources directory
echo "Copying Swift bindings..."
cp ArkDrop.swift ArkDrop-Swift-Package/Sources/ArkDrop/

# Copy Package.swift
echo "Copying Package.swift..."
cp Package.swift ArkDrop-Swift-Package/

# Copy header and modulemap for reference
echo "Copying headers and modulemap..."
cp arkdrop_uniffiFFI.h ArkDrop-Swift-Package/
cp module.modulemap ArkDrop-Swift-Package/

# Create README with usage instructions
cat > ArkDrop-Swift-Package/README.md << 'EOF'
# ArkDrop Swift Bindings

This package contains Swift bindings for ARK Drop.

## Contents

- `arkdrop_uniffiFFI.xcframework` - Pre-built XCFramework for iOS and macOS
- `Sources/ArkDrop/ArkDrop.swift` - Swift bindings generated by UniFFI
- `Package.swift` - Swift Package Manager configuration
- `arkdrop_uniffiFFI.h` - C header file (reference)
- `module.modulemap` - Module map (reference)

## Installation

### Swift Package Manager

Add to your `Package.swift`:

```swift
dependencies: [
.package(path: "path/to/ArkDrop-Swift-Package")
]
```

Or add the extracted package directory to your Xcode project via:
File → Add Package Dependencies → Add Local...

## Usage

Import the module in your Swift code:

```swift
import ArkDrop
```
EOF

# List package contents
echo ""
echo "Package contents:"
find ArkDrop-Swift-Package -type f | sort

# Create a zip archive
echo ""
echo "Creating archive..."
zip -r ArkDrop-Swift-Package.zip ArkDrop-Swift-Package/

# Create checksum
echo "Creating checksum..."
shasum -a 256 ArkDrop-Swift-Package.zip > ArkDrop-Swift-Package.zip.sha256

echo ""
echo "Package created successfully!"
cat ArkDrop-Swift-Package.zip.sha256

- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: swift-bindings
path: |
drop-core/uniffi/bindings/swift/ArkDrop-Swift-Package.zip
drop-core/uniffi/bindings/swift/ArkDrop-Swift-Package.zip.sha256
retention-days: 30

- name: Create Release
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
uses: softprops/action-gh-release@v2
with:
tag_name: swift-bindings-${{ github.run_id }}
name: Swift Bindings Release ${{ github.run_id }}
draft: false
prerelease: false
files: |
drop-core/uniffi/bindings/swift/ArkDrop-Swift-Package.zip
drop-core/uniffi/bindings/swift/ArkDrop-Swift-Package.zip.sha256
body: |
## Swift Bindings for ARK Drop

This release contains the Swift bindings for ARK Drop, including:
- XCFramework for iOS (device and simulator) and macOS
- Swift source files
- Swift Package Manager configuration

### Installation

#### Swift Package Manager

1. Download and extract `ArkDrop-Swift-Package.zip`
2. Add the package to your Xcode project or include it in your `Package.swift`:

```swift
dependencies: [
.package(path: "path/to/ArkDrop-Swift-Package")
]
```

#### Manual Installation

1. Download `ArkDrop-Swift-Package.zip`
2. Extract and add `arkdrop_uniffiFFI.xcframework` to your Xcode project
3. Add `drop.swift` to your project sources

### Verification

Verify the package integrity using the SHA256 checksum:
```bash
shasum -a 256 -c ArkDrop-Swift-Package.zip.sha256
```

Generated from commit: ${{ github.sha }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7 changes: 6 additions & 1 deletion drop-core/uniffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@ edition = "2024"

[lib]
name = "arkdrop_uniffi"
crate-type = ["cdylib"]
crate-type = ["staticlib", "cdylib"]
bench = false

[[bin]]
name = "uniffi-bindgen"
path = "uniffi-bindgen.rs"
bench = false

[[bin]]
name = "uniffi-bindgen-swift"
path = "uniffi-bindgen-swift.rs"
bench = false

[dependencies]
arkdropx-sender = { path = "../exchanges/sender" }
arkdropx-receiver = { path = "../exchanges/receiver" }
Expand Down
21 changes: 21 additions & 0 deletions drop-core/uniffi/bindings/swift/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Build artifacts
build/
*.xcframework

# Generated files from uniffi-bindgen
ArkDrop.swift
arkdrop_uniffiFFI.h
module.modulemap
arkdrop_uniffiFFI.modulemap

# Swift Package Manager
.build/
.swiftpm/

# Xcode
xcuserdata/
*.xcworkspace
DerivedData/

# macOS
.DS_Store
29 changes: 29 additions & 0 deletions drop-core/uniffi/bindings/swift/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "ArkDrop",
platforms: [
.iOS(.v13),
.macOS(.v10_15)
],
products: [
.library(
name: "ArkDrop",
targets: ["ArkDrop"]
),
],
targets: [
.target(
name: "ArkDrop",
dependencies: ["arkdrop_uniffiFFI"],
path: "Sources"
),
.binaryTarget(
name: "arkdrop_uniffiFFI",
path: "arkdrop_uniffiFFI.xcframework"
)
]
)
Loading
Loading