Skip to content

Commit 6119d19

Browse files
committed
update xtask
1 parent 929f992 commit 6119d19

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

xtask/src/swift.rs

+31-9
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,15 @@ fn generate_uniffi(library_file: &Path, ffi_directory: &Path) -> Result<()> {
115115
}
116116

117117
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+
}
119127

120128
// The builtin dev profile has its files stored under target/debug, all
121129
// other targets have matching directory names
@@ -147,20 +155,25 @@ fn build_xcframework(
147155

148156
(vec![build_path.clone()], build_path)
149157
} else {
150-
println!("-- Building for iOS [1/5]");
158+
println!("-- Building for iOS [1/7]");
151159
let ios_path = build_for_target("aarch64-apple-ios", profile)?;
152160

153-
println!("-- Building for macOS (Apple Silicon) [2/5]");
161+
println!("-- Building for macOS (Apple Silicon) [2/7]");
154162
let darwin_arm_path = build_for_target("aarch64-apple-darwin", profile)?;
155-
println!("-- Building for macOS (Intel) [3/5]");
163+
println!("-- Building for macOS (Intel) [3/7]");
156164
let darwin_x86_path = build_for_target("x86_64-apple-darwin", profile)?;
157165

158-
println!("-- Building for iOS Simulator (Apple Silicon) [4/5]");
166+
println!("-- Building for Mac Catalyst (Apple Silicon) [4/7]");
167+
let catalyst_arm_path = build_for_target("aarch64-apple-ios-macabi", profile)?;
168+
println!("-- Building for Mac Catalyst (Intel) [5/7]");
169+
let catalyst_x86_path = build_for_target("x86_64-apple-ios-macabi", profile)?;
170+
171+
println!("-- Building for iOS Simulator (Apple Silicon) [6/7]");
159172
let ios_sim_arm_path = build_for_target("aarch64-apple-ios-sim", profile)?;
160-
println!("-- Building for iOS Simulator (Intel) [5/5]");
173+
println!("-- Building for iOS Simulator (Intel) [7/7]");
161174
let ios_sim_x86_path = build_for_target("x86_64-apple-ios", profile)?;
162175

163-
println!("-- Running Lipo for macOS [1/2]");
176+
println!("-- Running Lipo for macOS [1/3]");
164177
// # macOS
165178
let lipo_target_macos = generated_dir.join("libmatrix_sdk_ffi_macos.a");
166179
cmd!(
@@ -169,15 +182,24 @@ fn build_xcframework(
169182
)
170183
.run()?;
171184

172-
println!("-- Running Lipo for iOS Simulator [2/2]");
185+
println!("-- Running Lipo for Mac Catalyst [2/3]");
186+
// # Catalyst
187+
let lipo_target_catalyst = generated_dir.join("libmatrix_sdk_ffi_catalyst.a");
188+
cmd!(
189+
"lipo -create {catalyst_x86_path} {catalyst_arm_path}
190+
-output {lipo_target_catalyst}"
191+
)
192+
.run()?;
193+
194+
println!("-- Running Lipo for iOS Simulator [3/3]");
173195
// # iOS Simulator
174196
let lipo_target_sim = generated_dir.join("libmatrix_sdk_ffi_iossimulator.a");
175197
cmd!(
176198
"lipo -create {ios_sim_arm_path} {ios_sim_x86_path}
177199
-output {lipo_target_sim}"
178200
)
179201
.run()?;
180-
(vec![lipo_target_macos, lipo_target_sim, ios_path], darwin_x86_path)
202+
(vec![lipo_target_macos, lipo_target_catalyst, lipo_target_sim, ios_path], darwin_x86_path)
181203
};
182204

183205
println!("-- Generating uniffi files");

0 commit comments

Comments
 (0)