@@ -115,7 +115,15 @@ fn generate_uniffi(library_file: &Path, ffi_directory: &Path) -> Result<()> {
115
115
}
116
116
117
117
fn build_for_target ( target : & str , profile : & str ) -> Result < PathBuf > {
118
- cmd ! ( "cargo build -p matrix-sdk-ffi --target {target} --profile {profile}" ) . run ( ) ?;
118
+ let is_catalyst = target. ends_with ( "-macabi" ) ;
119
+ if is_catalyst {
120
+ const CATALYST_RUST_NIGHTLY : & str = "nightly" ;
121
+ cmd ! ( "rustup toolchain install {CATALYST_RUST_NIGHTLY} --no-self-update" ) . run ( ) ?;
122
+ cmd ! ( "rustup component add rust-src --toolchain {CATALYST_RUST_NIGHTLY}" ) . run ( ) ?;
123
+ cmd ! ( "cargo +{CATALYST_RUST_NIGHTLY} build -p matrix-sdk-ffi -Z build-std --target {target} --profile {profile}" ) . run ( ) ?;
124
+ } else {
125
+ cmd ! ( "cargo build -p matrix-sdk-ffi --target {target} --profile {profile}" ) . run ( ) ?;
126
+ }
119
127
120
128
// The builtin dev profile has its files stored under target/debug, all
121
129
// other targets have matching directory names
@@ -142,20 +150,25 @@ fn build_xcframework(
142
150
143
151
( vec ! [ build_path. clone( ) ] , build_path)
144
152
} else {
145
- println ! ( "-- Building for iOS [1/5 ]" ) ;
153
+ println ! ( "-- Building for iOS [1/7 ]" ) ;
146
154
let ios_path = build_for_target ( "aarch64-apple-ios" , profile) ?;
147
155
148
- println ! ( "-- Building for macOS (Apple Silicon) [2/5 ]" ) ;
156
+ println ! ( "-- Building for macOS (Apple Silicon) [2/7 ]" ) ;
149
157
let darwin_arm_path = build_for_target ( "aarch64-apple-darwin" , profile) ?;
150
- println ! ( "-- Building for macOS (Intel) [3/5 ]" ) ;
158
+ println ! ( "-- Building for macOS (Intel) [3/7 ]" ) ;
151
159
let darwin_x86_path = build_for_target ( "x86_64-apple-darwin" , profile) ?;
152
160
153
- println ! ( "-- Building for iOS Simulator (Apple Silicon) [4/5]" ) ;
161
+ println ! ( "-- Building for Mac Catalyst (Apple Silicon) [4/7]" ) ;
162
+ let catalyst_arm_path = build_for_target ( "aarch64-apple-ios-macabi" , profile) ?;
163
+ println ! ( "-- Building for Mac Catalyst (Intel) [5/7]" ) ;
164
+ let catalyst_x86_path = build_for_target ( "x86_64-apple-ios-macabi" , profile) ?;
165
+
166
+ println ! ( "-- Building for iOS Simulator (Apple Silicon) [6/7]" ) ;
154
167
let ios_sim_arm_path = build_for_target ( "aarch64-apple-ios-sim" , profile) ?;
155
- println ! ( "-- Building for iOS Simulator (Intel) [5/5 ]" ) ;
168
+ println ! ( "-- Building for iOS Simulator (Intel) [7/7 ]" ) ;
156
169
let ios_sim_x86_path = build_for_target ( "x86_64-apple-ios" , profile) ?;
157
170
158
- println ! ( "-- Running Lipo for macOS [1/2 ]" ) ;
171
+ println ! ( "-- Running Lipo for macOS [1/3 ]" ) ;
159
172
// # macOS
160
173
let lipo_target_macos = generated_dir. join ( "libmatrix_sdk_ffi_macos.a" ) ;
161
174
cmd ! (
@@ -164,15 +177,24 @@ fn build_xcframework(
164
177
)
165
178
. run ( ) ?;
166
179
167
- println ! ( "-- Running Lipo for iOS Simulator [2/2]" ) ;
180
+ println ! ( "-- Running Lipo for Mac Catalyst [2/3]" ) ;
181
+ // # Catalyst
182
+ let lipo_target_catalyst = generated_dir. join ( "libmatrix_sdk_ffi_catalyst.a" ) ;
183
+ cmd ! (
184
+ "lipo -create {catalyst_x86_path} {catalyst_arm_path}
185
+ -output {lipo_target_catalyst}"
186
+ )
187
+ . run ( ) ?;
188
+
189
+ println ! ( "-- Running Lipo for iOS Simulator [3/3]" ) ;
168
190
// # iOS Simulator
169
191
let lipo_target_sim = generated_dir. join ( "libmatrix_sdk_ffi_iossimulator.a" ) ;
170
192
cmd ! (
171
193
"lipo -create {ios_sim_arm_path} {ios_sim_x86_path}
172
194
-output {lipo_target_sim}"
173
195
)
174
196
. run ( ) ?;
175
- ( vec ! [ lipo_target_macos, lipo_target_sim, ios_path] , darwin_x86_path)
197
+ ( vec ! [ lipo_target_macos, lipo_target_catalyst , lipo_target_sim, ios_path] , darwin_x86_path)
176
198
} ;
177
199
178
200
println ! ( "-- Generating uniffi files" ) ;
0 commit comments