@@ -8,57 +8,71 @@ cargo run --bin uniffi-bindgen generate \
88 --language swift \
99 --out-dir " generated/swift"
1010
11+ # Required for xcframework
1112mv ./generated/swift/livekit_uniffiFFI.modulemap ./generated/swift/module.modulemap
1213
13- rustup target add aarch64-apple-darwin
14- rustup target add x86_64-apple-darwin
15- rustup target add aarch64-apple-ios
16- rustup target add aarch64-apple-ios-sim
17- rustup target add x86_64-apple-ios
18- rustup target add aarch64-apple-ios-macabi
19- rustup target add x86_64-apple-ios-macabi
14+ RUSTUP_TARGETS=(
15+ aarch64-apple-darwin
16+ x86_64-apple-darwin
17+ aarch64-apple-ios
18+ aarch64-apple-ios-sim
19+ x86_64-apple-ios
20+ aarch64-apple-ios-macabi
21+ x86_64-apple-ios-macabi
22+ )
2023
21- cargo build --release --target aarch64-apple-darwin
22- cargo build --release --target x86_64-apple-darwin
23- cargo build --release --target aarch64-apple-ios
24- cargo build --release --target aarch64-apple-ios-sim
25- cargo build --release --target x86_64-apple-ios
26- cargo build --release --target aarch64-apple-ios-macabi
27- cargo build --release --target x86_64-apple-ios-macabi
24+ TIER3_TARGETS=(
25+ aarch64-apple-tvos
26+ aarch64-apple-visionos
27+ aarch64-apple-tvos-sim
28+ aarch64-apple-visionos-sim
29+ )
2830
29- # Tier 3 targets: tvOS, visionOS
30- cargo +nightly build -Zbuild-std=std,panic_abort --release --target=aarch64-apple-tvos
31- cargo +nightly build -Zbuild-std=std,panic_abort --release --target=aarch64-apple-visionos
32- cargo +nightly build -Zbuild-std=std,panic_abort --release --target=aarch64-apple-tvos-sim
33- cargo +nightly build -Zbuild-std=std,panic_abort --release --target=aarch64-apple-visionos-sim
31+ for target in " ${RUSTUP_TARGETS[@]} " ; do
32+ rustup target add " $target "
33+ done
3434
35- mkdir -p ../target/ios-simulator/release
36- lipo -create \
37- ../target/aarch64-apple-ios-sim/release/liblivekit_uniffi.a \
38- ../target/x86_64-apple-ios/release/liblivekit_uniffi.a \
39- -output ../target/ios-simulator/release/liblivekit_uniffi.a
35+ for target in " ${RUSTUP_TARGETS[@]} " ; do
36+ cargo build --release --target " $target "
37+ done
4038
41- mkdir -p ../target/macos/release
42- lipo -create \
43- ../target/aarch64-apple-darwin/release/liblivekit_uniffi.a \
44- ../target/x86_64-apple-darwin/release/liblivekit_uniffi.a \
45- -output ../target/macos/release/liblivekit_uniffi.a
39+ for target in " ${TIER3_TARGETS[@]} " ; do
40+ cargo +nightly build -Zbuild-std=std,panic_abort --release --target=" $target "
41+ done
4642
47- mkdir -p ../target/ios-macabi/release
48- lipo -create \
49- ../target/aarch64-apple-ios-macabi/release/liblivekit_uniffi.a \
50- ../target/x86_64-apple-ios-macabi/release/liblivekit_uniffi.a \
51- -output ../target/ios-macabi/release/liblivekit_uniffi.a
43+ UNIVERSAL_BINARIES=(
44+ " ios-simulator:aarch64-apple-ios-sim:x86_64-apple-ios"
45+ " macos:aarch64-apple-darwin:x86_64-apple-darwin"
46+ " ios-macabi:aarch64-apple-ios-macabi:x86_64-apple-ios-macabi"
47+ )
48+
49+ for config in " ${UNIVERSAL_BINARIES[@]} " ; do
50+ IFS=' :' read -r output_dir arch1 arch2 <<< " $config"
51+ mkdir -p " ../target/${output_dir} /release"
52+ lipo -create \
53+ " ../target/${arch1} /release/liblivekit_uniffi.a" \
54+ " ../target/${arch2} /release/liblivekit_uniffi.a" \
55+ -output " ../target/${output_dir} /release/liblivekit_uniffi.a"
56+ done
5257
5358rm -rf ../target/LiveKitFFI.xcframework
5459
60+ XCFRAMEWORK_LIBS=(
61+ " ../target/aarch64-apple-ios/release/liblivekit_uniffi.a"
62+ " ../target/ios-simulator/release/liblivekit_uniffi.a"
63+ " ../target/macos/release/liblivekit_uniffi.a"
64+ " ../target/ios-macabi/release/liblivekit_uniffi.a"
65+ " ../target/aarch64-apple-tvos/release/liblivekit_uniffi.a"
66+ " ../target/aarch64-apple-visionos/release/liblivekit_uniffi.a"
67+ " ../target/aarch64-apple-tvos-sim/release/liblivekit_uniffi.a"
68+ " ../target/aarch64-apple-visionos-sim/release/liblivekit_uniffi.a"
69+ )
70+
71+ XCFRAMEWORK_ARGS=()
72+ for lib in " ${XCFRAMEWORK_LIBS[@]} " ; do
73+ XCFRAMEWORK_ARGS+=(-library " $lib " -headers ./generated/swift)
74+ done
75+
5576xcodebuild -create-xcframework \
56- -library ../target/aarch64-apple-ios/release/liblivekit_uniffi.a -headers ./generated/swift \
57- -library ../target/ios-simulator/release/liblivekit_uniffi.a -headers ./generated/swift \
58- -library ../target/macos/release/liblivekit_uniffi.a -headers ./generated/swift \
59- -library ../target/ios-macabi/release/liblivekit_uniffi.a -headers ./generated/swift \
60- -library ../target/aarch64-apple-tvos/release/liblivekit_uniffi.a -headers ./generated/swift \
61- -library ../target/aarch64-apple-visionos/release/liblivekit_uniffi.a -headers ./generated/swift \
62- -library ../target/aarch64-apple-tvos-sim/release/liblivekit_uniffi.a -headers ./generated/swift \
63- -library ../target/aarch64-apple-visionos-sim/release/liblivekit_uniffi.a -headers ./generated/swift \
77+ " ${XCFRAMEWORK_ARGS[@]} " \
6478 -output " ../target/LiveKitFFI.xcframework"
0 commit comments