Skip to content

Commit 92b50a3

Browse files
authored
fix(cli): add support to Xcode's archive (#8209)
1 parent 977d0e5 commit 92b50a3

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

.changes/xcode-archive.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"tauri-cli": patch:bug
3+
"@tauri-apps/cli": patch:bug
4+
---
5+
6+
Added support to Xcode's archive. This requires regenerating the Xcode project.

tooling/cli/src/mobile/ios/xcode_script.rs

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -134,22 +134,17 @@ pub fn command(options: Options) -> Result<()> {
134134

135135
let isysroot = format!("-isysroot {}", options.sdk_root.display());
136136

137-
// when using Xcode, the arches will be ['Simulator', 'arm64'] instead of ['arm64-sim']
138-
let arches = if options.arches.contains(&"Simulator".into()) {
139-
vec![if cfg!(target_arch = "aarch64") {
140-
"arm64-sim".to_string()
141-
} else {
142-
"x86_64".to_string()
143-
}]
144-
} else {
145-
options.arches
146-
};
147-
for arch in arches {
137+
for arch in options.arches {
148138
// Set target-specific flags
149139
let (env_triple, rust_triple) = match arch.as_str() {
150140
"arm64" => ("aarch64_apple_ios", "aarch64-apple-ios"),
151141
"arm64-sim" => ("aarch64_apple_ios_sim", "aarch64-apple-ios-sim"),
152142
"x86_64" => ("x86_64_apple_ios", "x86_64-apple-ios"),
143+
"Simulator" => {
144+
// when using Xcode, the arches for a simulator build will be ['Simulator', 'arm64-sim'] instead of ['arm64-sim']
145+
// so we ignore that on our end
146+
continue;
147+
}
153148
_ => {
154149
return Err(anyhow::anyhow!(
155150
"Arch specified by Xcode was invalid. {} isn't a known arch",
@@ -206,14 +201,11 @@ pub fn command(options: Options) -> Result<()> {
206201
}
207202

208203
let project_dir = config.project_dir();
209-
std::fs::create_dir_all(project_dir.join(format!("Externals/{}", profile.as_str())))?;
204+
let externals_lib_dir = project_dir.join(format!("Externals/{arch}/{}", profile.as_str()));
205+
std::fs::create_dir_all(&externals_lib_dir)?;
210206
std::fs::copy(
211207
lib_path,
212-
project_dir.join(format!(
213-
"Externals/{}/lib{}.a",
214-
profile.as_str(),
215-
config.app().lib_name()
216-
)),
208+
externals_lib_dir.join(format!("lib{}.a", config.app().lib_name())),
217209
)?;
218210
}
219211
Ok(())

tooling/cli/templates/mobile/ios/project.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,12 @@ targets:
7575
ENABLE_BITCODE: false
7676
ARCHS: [{{join ios-valid-archs}}]
7777
VALID_ARCHS: {{~#each ios-valid-archs}} {{this}} {{/each}}
78-
LIBRARY_SEARCH_PATHS[arch=x86_64]: $(inherited) $(PROJECT_DIR)/Externals/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)
79-
LIBRARY_SEARCH_PATHS[arch=arm64]: $(inherited) $(PROJECT_DIR)/Externals/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)
80-
LIBRARY_SEARCH_PATHS[arch=arm64-sim]: $(inherited) $(PROJECT_DIR)/Externals/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)
78+
LIBRARY_SEARCH_PATHS[arch=x86_64]: $(inherited) $(PROJECT_DIR)/Externals/x86_64/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)
79+
LIBRARY_SEARCH_PATHS[arch=arm64]: $(inherited) $(PROJECT_DIR)/Externals/arm64/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)
80+
LIBRARY_SEARCH_PATHS[arch=arm64-sim]: $(inherited) $(PROJECT_DIR)/Externals/arm64-sim/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)
8181
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES: true
82+
EXCLUDED_ARCHS[sdk=iphonesimulator*]: arm64
83+
EXCLUDED_ARCHS[sdk=iphoneos*]: arm64-sim x86_64
8284
groups: [app]
8385
dependencies:
8486
- framework: lib{{app.lib-name}}.a

0 commit comments

Comments
 (0)