@@ -10,7 +10,7 @@ TARGET_DIR="${SRC_ROOT}/target"
1010
1111GENERATED_DIR=" ${SRC_ROOT} /generated"
1212if [ -d " ${GENERATED_DIR} " ]; then rm -rf " ${GENERATED_DIR} " ; fi
13- mkdir -p ${GENERATED_DIR} /{macos,simulator}
13+ mkdir -p ${GENERATED_DIR} /{macos,simulator,catalyst }
1414
1515REL_FLAG=" --release"
1616REL_TYPE_DIR=" release"
@@ -19,23 +19,38 @@ TARGET_CRATE=matrix-sdk-crypto-ffi
1919
2020# Build static libs for all the different architectures
2121
22- # Required by olm-sys crate
22+ # Required by olm-sys crate. @todo: Is this the right SDK path for Catalyst as well?
2323export IOS_SDK_PATH=` xcrun --show-sdk-path --sdk iphoneos`
2424
2525# iOS
26- echo -e " Building for iOS [1/5 ]"
26+ echo -e " Building for iOS [1/7 ]"
2727cargo build -p ${TARGET_CRATE} ${REL_FLAG} --target " aarch64-apple-ios"
2828
29+ # Mac Catalyst
30+ # 1) The target has no pre=built rust-std, so we use `-Z build-std`.
31+ # how to build-std: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#build-std
32+ # list of targets with prebuilt rust-std: https://doc.rust-lang.org/nightly/rustc/platform-support.html
33+ # 2) requires a recent nightly wih https://github.com/rust-lang/rust/pull/111384 merged
34+ CATALYST_RUST_NIGHTLY=" nightly"
35+ echo -e " \nInstalling nightly and rust-src for Mac Catalyst"
36+ rustup toolchain install ${CATALYST_RUST_NIGHTLY} --no-self-update
37+ rustup component add rust-src --toolchain ${CATALYST_RUST_NIGHTLY}
38+
39+ echo -e " \nBuilding for macOS Catalyst (Apple Silicon) [2/7]"
40+ cargo +${CATALYST_RUST_NIGHTLY} build -p ${TARGET_CRATE} ${REL_FLAG} -Z build-std --target aarch64-apple-ios-macabi
41+ echo -e " \nBuilding for macOS Catalyst (Intel) [3/7]"
42+ cargo +${CATALYST_RUST_NIGHTLY} build -p ${TARGET_CRATE} ${REL_FLAG} -Z build-std --target x86_64-apple-ios-macabi
43+
2944# MacOS
30- echo -e " \nBuilding for macOS (Apple Silicon) [2/5 ]"
45+ echo -e " \nBuilding for macOS (Apple Silicon) [4/7 ]"
3146cargo build -p ${TARGET_CRATE} ${REL_FLAG} --target " aarch64-apple-darwin"
32- echo -e " \nBuilding for macOS (Intel) [3/5 ]"
47+ echo -e " \nBuilding for macOS (Intel) [5/7 ]"
3348cargo build -p ${TARGET_CRATE} ${REL_FLAG} --target " x86_64-apple-darwin"
3449
3550# iOS Simulator
36- echo -e " \nBuilding for iOS Simulator (Apple Silicon) [4/5 ]"
51+ echo -e " \nBuilding for iOS Simulator (Apple Silicon) [6/7 ]"
3752cargo build -p ${TARGET_CRATE} ${REL_FLAG} --target " aarch64-apple-ios-sim"
38- echo -e " \nBuilding for iOS Simulator (Intel) [5/5 ]"
53+ echo -e " \nBuilding for iOS Simulator (Intel) [7/7 ]"
3954cargo build -p ${TARGET_CRATE} ${REL_FLAG} --target " x86_64-apple-ios"
4055
4156echo -e " \nCreating XCFramework"
@@ -47,6 +62,12 @@ lipo -create \
4762 " ${TARGET_DIR} /aarch64-apple-darwin/${REL_TYPE_DIR} /libmatrix_sdk_crypto_ffi.a" \
4863 -output " ${GENERATED_DIR} /macos/libmatrix_sdk_crypto_ffi.a"
4964
65+ # Catalyst
66+ lipo -create \
67+ " ${TARGET_DIR} /aarch64-apple-ios-macabi/${REL_TYPE_DIR} /libmatrix_sdk_crypto_ffi.a" \
68+ " ${TARGET_DIR} /x86_64-apple-ios-macabi/${REL_TYPE_DIR} /libmatrix_sdk_crypto_ffi.a" \
69+ -output " ${GENERATED_DIR} /catalyst/libmatrix_sdk_crypto_ffi.a"
70+
5071# iOS Simulator
5172lipo -create \
5273 " ${TARGET_DIR} /x86_64-apple-ios/${REL_TYPE_DIR} /libmatrix_sdk_crypto_ffi.a" \
@@ -85,10 +106,13 @@ xcodebuild -create-xcframework \
85106 -headers ${HEADERS_DIR} \
86107 -library " ${GENERATED_DIR} /simulator/libmatrix_sdk_crypto_ffi.a" \
87108 -headers ${HEADERS_DIR} \
109+ -library " ${GENERATED_DIR} /catalyst/libmatrix_sdk_crypto_ffi.a" \
110+ -headers ${HEADERS_DIR} \
88111 -output " ${GENERATED_DIR} /MatrixSDKCryptoFFI.xcframework"
89112
90113# Cleanup
91114if [ -d " ${GENERATED_DIR} /macos" ]; then rm -rf " ${GENERATED_DIR} /macos" ; fi
115+ if [ -d " ${GENERATED_DIR} /catalyst" ]; then rm -rf " ${GENERATED_DIR} /catalyst" ; fi
92116if [ -d " ${GENERATED_DIR} /simulator" ]; then rm -rf " ${GENERATED_DIR} /simulator" ; fi
93117if [ -d ${HEADERS_DIR} ]; then rm -rf ${HEADERS_DIR} ; fi
94118
0 commit comments