Add iOS build target for fluxa_core

Phase 0 of the fluxa-android KMP/CMP migration needs an xcframework +
Swift UniFFI bindings for fluxa_core. Adds an "ios" feature (full-api +
uniffi-bindings, no jni/dolby_vision, mirroring the existing "desktop"
feature), a staticlib crate-type for xcframework embedding, a
[bindings.swift] uniffi.toml section, and a macOS-only build script
that produces FluxaCore.xcframework for aarch64-apple-ios and
aarch64-apple-ios-sim.

Verified on Linux: `cargo check --target aarch64-apple-ios --features
ios` and the aarch64-apple-ios-sim equivalent both compile cleanly, so
the crate itself has no Android/JNI-only code leaking into the iOS
feature set. Actual linking/xcframework packaging needs a Mac with
Xcode — untested here.
This commit is contained in:
KhooLy 2026-07-13 02:36:38 +03:00
parent a0df2534a6
commit 79a728d4f7
3 changed files with 57 additions and 1 deletions

View file

@ -32,7 +32,7 @@ version = "0.1.0"
edition = "2021"
[lib]
crate-type = ["cdylib", "rlib"]
crate-type = ["cdylib", "staticlib", "rlib"]
[lints]
workspace = true
@ -51,6 +51,7 @@ native = [
"uniffi-bindings",
]
desktop = ["full-api"]
ios = ["full-api", "uniffi-bindings"]
full-api = []
streaming-shared = []
uniffi-bindings = ["dep:uniffi", "full-api"]

View file

@ -0,0 +1,51 @@
#!/usr/bin/env bash
set -euo pipefail
if [[ "$(uname)" != "Darwin" ]]; then
echo "error: this script requires macOS with Xcode command line tools installed" >&2
exit 1
fi
if ! command -v xcodebuild >/dev/null 2>&1; then
echo "error: xcodebuild not found — install Xcode" >&2
exit 1
fi
cd "$(dirname "$0")/.."
TARGETS=(aarch64-apple-ios aarch64-apple-ios-sim)
for target in "${TARGETS[@]}"; do
rustup target add "$target"
done
for target in "${TARGETS[@]}"; do
cargo build --release --target "$target" --no-default-features --features ios --lib
done
BINDINGS_DIR="target/uniffi-swift"
rm -rf "$BINDINGS_DIR"
mkdir -p "$BINDINGS_DIR"
cargo run --features uniffi-cli --bin uniffi-bindgen generate \
--library "target/aarch64-apple-ios/release/libfluxa_core.a" \
--language swift \
--config uniffi.toml \
--out-dir "$BINDINGS_DIR"
HEADERS_DIR="$BINDINGS_DIR/Headers"
mkdir -p "$HEADERS_DIR"
mv "$BINDINGS_DIR"/*.h "$HEADERS_DIR"/
mv "$BINDINGS_DIR"/*.modulemap "$HEADERS_DIR/module.modulemap"
XCFRAMEWORK_OUT="build/ios/FluxaCore.xcframework"
rm -rf "build/ios"
mkdir -p "build/ios"
xcodebuild -create-xcframework \
-library "target/aarch64-apple-ios/release/libfluxa_core.a" -headers "$HEADERS_DIR" \
-library "target/aarch64-apple-ios-sim/release/libfluxa_core.a" -headers "$HEADERS_DIR" \
-output "$XCFRAMEWORK_OUT"
echo "xcframework: $XCFRAMEWORK_OUT"
echo "Swift bindings: $BINDINGS_DIR"/*.swift

View file

@ -3,3 +3,7 @@ package_name = "com.fluxa.core.uniffi"
android = true
cdylib_name = "fluxa_core"
kotlin_target_version = "2.3.0"
[bindings.swift]
module_name = "FluxaCore"
cdylib_name = "fluxa_core"