mirror of
https://github.com/tauri-apps/cargo-mobile2.git
synced 2026-01-31 00:35:21 +01:00
fix(apple): simulator build on Intel machines (#479)
* fix(apple): simulator build on Intel machines ref https://github.com/tauri-apps/tauri/issues/13456 * ARCHS instead of -arch * use iphone 13 for swiftCompatibilityConcurrency? * change file
This commit is contained in:
committed by
GitHub
parent
c0c0738a05
commit
60cf1eae5c
5
.changes/fix-simulator-build-intel.md
Normal file
5
.changes/fix-simulator-build-intel.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"cargo-mobile2": patch
|
||||
---
|
||||
|
||||
Fix build and archive not working on Apple Intel systems when targeting the simulator.
|
||||
@@ -524,7 +524,18 @@ impl<'a> Target<'a> {
|
||||
None
|
||||
};
|
||||
|
||||
let destination = target_device.map(|device| format!("id={}", device.id()));
|
||||
let destination = target_device
|
||||
.map(|device| format!("id={}", device.id()))
|
||||
.or_else(|| {
|
||||
if cfg!(target_arch = "x86_64") && self.sdk == "iphonesimulator" {
|
||||
// on Intel we must force the destination when targeting the simulator
|
||||
// otherwise xcodebuild tries to build arm64
|
||||
// iPhone 13 seems like a good default target, old enough for every Xcode out there to have it?
|
||||
Some("platform=iOS Simulator,name=iPhone 13".to_string())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
});
|
||||
|
||||
let args: Vec<OsString> = vec![];
|
||||
duct::cmd("xcodebuild", args)
|
||||
@@ -541,6 +552,12 @@ impl<'a> Target<'a> {
|
||||
cmd.args(["-destination", destination]);
|
||||
}
|
||||
|
||||
if cfg!(target_arch = "x86_64") && sdk == "iphonesimulator" {
|
||||
// on Intel we must force the ARCHS when targeting the simulator
|
||||
// otherwise xcodebuild tries to build arm64
|
||||
cmd.arg("ARCHS=x86_64");
|
||||
}
|
||||
|
||||
cmd.args(["-scheme", &scheme])
|
||||
.arg("-workspace")
|
||||
.arg(&workspace_path)
|
||||
@@ -588,6 +605,7 @@ impl<'a> Target<'a> {
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let args: Vec<OsString> = vec![];
|
||||
duct::cmd("xcodebuild", args)
|
||||
.full_env(env.explicit_env())
|
||||
@@ -600,6 +618,15 @@ impl<'a> Target<'a> {
|
||||
if let Some(a) = &arch {
|
||||
cmd.args(["-arch", a]);
|
||||
}
|
||||
|
||||
if cfg!(target_arch = "x86_64") && sdk == "iphonesimulator" {
|
||||
// on Intel we must force the ARCHS and destination when targeting the simulator
|
||||
// otherwise xcodebuild tries to build arm64
|
||||
// iPhone 13 seems like a good default target, old enough for every Xcode out there to have it?
|
||||
cmd.args(["-destination", "platform=iOS Simulator,name=iPhone 13"])
|
||||
.arg("ARCHS=x86_64");
|
||||
}
|
||||
|
||||
cmd.args(["-scheme", &scheme])
|
||||
.arg("-workspace")
|
||||
.arg(&workspace_path)
|
||||
|
||||
Reference in New Issue
Block a user