@@ -10,7 +10,7 @@ TARGET_DIR="${SRC_ROOT}/target"
10
10
11
11
GENERATED_DIR=" ${SRC_ROOT} /generated"
12
12
if [ -d " ${GENERATED_DIR} " ]; then rm -rf " ${GENERATED_DIR} " ; fi
13
- mkdir -p ${GENERATED_DIR} /{macos,simulator}
13
+ mkdir -p ${GENERATED_DIR} /{macos,simulator,catalyst }
14
14
15
15
REL_FLAG=" --release"
16
16
REL_TYPE_DIR=" release"
@@ -19,23 +19,38 @@ TARGET_CRATE=matrix-sdk-crypto-ffi
19
19
20
20
# Build static libs for all the different architectures
21
21
22
- # Required by olm-sys crate
22
+ # Required by olm-sys crate. @todo: Is this the right SDK path for Catalyst as well?
23
23
export IOS_SDK_PATH=` xcrun --show-sdk-path --sdk iphoneos`
24
24
25
25
# iOS
26
- echo -e " Building for iOS [1/5 ]"
26
+ echo -e " Building for iOS [1/7 ]"
27
27
cargo build -p ${TARGET_CRATE} ${REL_FLAG} --target " aarch64-apple-ios"
28
28
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
+
29
44
# MacOS
30
- echo -e " \nBuilding for macOS (Apple Silicon) [2/5 ]"
45
+ echo -e " \nBuilding for macOS (Apple Silicon) [4/7 ]"
31
46
cargo 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 ]"
33
48
cargo build -p ${TARGET_CRATE} ${REL_FLAG} --target " x86_64-apple-darwin"
34
49
35
50
# iOS Simulator
36
- echo -e " \nBuilding for iOS Simulator (Apple Silicon) [4/5 ]"
51
+ echo -e " \nBuilding for iOS Simulator (Apple Silicon) [6/7 ]"
37
52
cargo 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 ]"
39
54
cargo build -p ${TARGET_CRATE} ${REL_FLAG} --target " x86_64-apple-ios"
40
55
41
56
echo -e " \nCreating XCFramework"
@@ -47,6 +62,12 @@ lipo -create \
47
62
" ${TARGET_DIR} /aarch64-apple-darwin/${REL_TYPE_DIR} /libmatrix_sdk_crypto_ffi.a" \
48
63
-output " ${GENERATED_DIR} /macos/libmatrix_sdk_crypto_ffi.a"
49
64
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
+
50
71
# iOS Simulator
51
72
lipo -create \
52
73
" ${TARGET_DIR} /x86_64-apple-ios/${REL_TYPE_DIR} /libmatrix_sdk_crypto_ffi.a" \
@@ -85,10 +106,13 @@ xcodebuild -create-xcframework \
85
106
-headers ${HEADERS_DIR} \
86
107
-library " ${GENERATED_DIR} /simulator/libmatrix_sdk_crypto_ffi.a" \
87
108
-headers ${HEADERS_DIR} \
109
+ -library " ${GENERATED_DIR} /catalyst/libmatrix_sdk_crypto_ffi.a" \
110
+ -headers ${HEADERS_DIR} \
88
111
-output " ${GENERATED_DIR} /MatrixSDKCryptoFFI.xcframework"
89
112
90
113
# Cleanup
91
114
if [ -d " ${GENERATED_DIR} /macos" ]; then rm -rf " ${GENERATED_DIR} /macos" ; fi
115
+ if [ -d " ${GENERATED_DIR} /catalyst" ]; then rm -rf " ${GENERATED_DIR} /catalyst" ; fi
92
116
if [ -d " ${GENERATED_DIR} /simulator" ]; then rm -rf " ${GENERATED_DIR} /simulator" ; fi
93
117
if [ -d ${HEADERS_DIR} ]; then rm -rf ${HEADERS_DIR} ; fi
94
118
0 commit comments