Skip to content

Commit 28ebe52

Browse files
committed
feat: ios static lib
1 parent 86d5ccc commit 28ebe52

File tree

3 files changed

+84
-1
lines changed

3 files changed

+84
-1
lines changed

crates/uniffi/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version.workspace = true
44
edition.workspace = true
55

66
[lib]
7-
crate-type = ["cdylib", "lib"]
7+
crate-type = ["staticlib", "cdylib", "lib"]
88

99
[dependencies]
1010
dojo-core = { workspace = true }

scripts/build_ios.sh

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/bin/bash
2+
# Build script for iOS XCFramework and Swift bindings for Dojo
3+
4+
set -e
5+
6+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
8+
9+
# Colors
10+
GREEN='\033[0;32m'
11+
BLUE='\033[0;34m'
12+
YELLOW='\033[1;33m'
13+
RED='\033[0;31m'
14+
NC='\033[0m'
15+
16+
echo -e "${BLUE}=== Building Dojo iOS XCFramework ===${NC}"
17+
echo ""
18+
19+
# Check for required iOS targets
20+
echo -e "${YELLOW}Checking iOS targets...${NC}"
21+
if ! rustup target list --installed | grep -q "aarch64-apple-ios"; then
22+
echo "Installing aarch64-apple-ios..."
23+
rustup target add aarch64-apple-ios
24+
fi
25+
26+
if ! rustup target list --installed | grep -q "aarch64-apple-ios-sim"; then
27+
echo "Installing aarch64-apple-ios-sim..."
28+
rustup target add aarch64-apple-ios-sim
29+
fi
30+
echo -e "${GREEN}✓ iOS targets ready${NC}"
31+
echo ""
32+
33+
# Step 1: Build for iOS device (arm64)
34+
echo -e "${YELLOW}Step 1/4:${NC} Building for iOS device (aarch64-apple-ios)..."
35+
cd "$PROJECT_ROOT"
36+
cargo build --release -p dojo-uniffi --target aarch64-apple-ios
37+
echo -e "${GREEN}✓ iOS device build complete${NC}"
38+
echo ""
39+
40+
# Step 2: Build for iOS simulator (arm64)
41+
echo -e "${YELLOW}Step 2/4:${NC} Building for iOS simulator (aarch64-apple-ios-sim)..."
42+
cargo build --release -p dojo-uniffi --target aarch64-apple-ios-sim
43+
echo -e "${GREEN}✓ iOS simulator build complete${NC}"
44+
echo ""
45+
46+
# Step 3: Generate Swift bindings
47+
echo -e "${YELLOW}Step 3/4:${NC} Generating Swift bindings..."
48+
./scripts/build_swift.sh
49+
echo -e "${GREEN}✓ Swift bindings generated${NC}"
50+
echo ""
51+
52+
# Step 4: Create XCFramework
53+
echo -e "${YELLOW}Step 4/4:${NC} Creating XCFramework..."
54+
rm -rf target/dojo_uniffi.xcframework
55+
xcodebuild -create-xcframework \
56+
-library target/aarch64-apple-ios/release/libdojo_uniffi.a \
57+
-library target/aarch64-apple-ios-sim/release/libdojo_uniffi.a \
58+
-output target/dojo_uniffi.xcframework
59+
echo -e "${GREEN}✓ XCFramework created${NC}"
60+
echo ""
61+
62+
echo -e "${GREEN}✅ Build complete!${NC}"
63+
echo ""
64+
echo -e "${BLUE}Summary:${NC}"
65+
echo " • XCFramework: target/dojo_uniffi.xcframework"
66+
echo " • iOS device: target/aarch64-apple-ios/release/libdojo_uniffi.a"
67+
echo " • iOS sim: target/aarch64-apple-ios-sim/release/libdojo_uniffi.a"
68+
echo " • Bindings: bindings/swift/"
69+
echo ""
70+

scripts/build_swift.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo "Building Swift bindings for dojo-uniffi..."
5+
6+
# Build the Rust library
7+
cargo build --release -p dojo-uniffi
8+
9+
# Generate Swift bindings
10+
cargo run --release --bin uniffi-bindgen-swift
11+
12+
echo "Swift bindings generated in bindings/swift/"
13+

0 commit comments

Comments
 (0)