Skip to content

Commit 4669416

Browse files
committed
update xtask
1 parent 6b06822 commit 4669416

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

xtask/src/swift.rs

Lines changed: 31 additions & 9 deletions
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
@@ -142,20 +150,25 @@ fn build_xcframework(
142150

143151
(vec![build_path.clone()], build_path)
144152
} else {
145-
println!("-- Building for iOS [1/5]");
153+
println!("-- Building for iOS [1/7]");
146154
let ios_path = build_for_target("aarch64-apple-ios", profile)?;
147155

148-
println!("-- Building for macOS (Apple Silicon) [2/5]");
156+
println!("-- Building for macOS (Apple Silicon) [2/7]");
149157
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]");
151159
let darwin_x86_path = build_for_target("x86_64-apple-darwin", profile)?;
152160

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]");
154167
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]");
156169
let ios_sim_x86_path = build_for_target("x86_64-apple-ios", profile)?;
157170

158-
println!("-- Running Lipo for macOS [1/2]");
171+
println!("-- Running Lipo for macOS [1/3]");
159172
// # macOS
160173
let lipo_target_macos = generated_dir.join("libmatrix_sdk_ffi_macos.a");
161174
cmd!(
@@ -164,15 +177,24 @@ fn build_xcframework(
164177
)
165178
.run()?;
166179

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]");
168190
// # iOS Simulator
169191
let lipo_target_sim = generated_dir.join("libmatrix_sdk_ffi_iossimulator.a");
170192
cmd!(
171193
"lipo -create {ios_sim_arm_path} {ios_sim_x86_path}
172194
-output {lipo_target_sim}"
173195
)
174196
.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)
176198
};
177199

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

0 commit comments

Comments
 (0)