Skip to content

Commit

Permalink
fix(cli): add support to Xcode's archive
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed Nov 10, 2023
1 parent e9aa727 commit 1a400c9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 20 deletions.
6 changes: 6 additions & 0 deletions .changes/xcode-archive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"tauri-cli": patch:bug
"@tauri-apps/cli": patch:bug
---

Added support to Xcode's archive. This requires regenerating the Xcode project.
33 changes: 16 additions & 17 deletions tooling/cli/src/mobile/ios/xcode_script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,22 +134,24 @@ pub fn command(options: Options) -> Result<()> {

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

// when using Xcode, the arches will be ['Simulator', 'arm64'] instead of ['arm64-sim']
let arches = if options.arches.contains(&"Simulator".into()) {
vec![if cfg!(target_arch = "aarch64") {
"arm64-sim".to_string()
} else {
"x86_64".to_string()
}]
} else {
options.arches
};
for arch in arches {
/*let simulator_platform_component =
std::path::Component::Normal(std::ffi::OsStr::new("iPhoneSimulator.platform"));
let simulator_build = options
.sdk_root
.components()
.any(|c| c == simulator_platform_component);*/

for arch in options.arches {
// Set target-specific flags
let (env_triple, rust_triple) = match arch.as_str() {
"arm64" => ("aarch64_apple_ios", "aarch64-apple-ios"),
"arm64-sim" => ("aarch64_apple_ios_sim", "aarch64-apple-ios-sim"),
"x86_64" => ("x86_64_apple_ios", "x86_64-apple-ios"),
"Simulator" => {
// when using Xcode, the arches for a simulator build will be ['Simulator', 'arm64-sim'] instead of ['arm64-sim']
// so we fix that on our end
continue;
}
_ => {
return Err(anyhow::anyhow!(
"Arch specified by Xcode was invalid. {} isn't a known arch",
Expand Down Expand Up @@ -206,14 +208,11 @@ pub fn command(options: Options) -> Result<()> {
}

let project_dir = config.project_dir();
std::fs::create_dir_all(project_dir.join(format!("Externals/{}", profile.as_str())))?;
let externals_lib_dir = project_dir.join(format!("Externals/{arch}/{}", profile.as_str()));
std::fs::create_dir_all(&externals_lib_dir)?;
std::fs::copy(
lib_path,
project_dir.join(format!(
"Externals/{}/lib{}.a",
profile.as_str(),
config.app().lib_name()
)),
externals_lib_dir.join(format!("lib{}.a", config.app().lib_name())),
)?;
}
Ok(())
Expand Down
8 changes: 5 additions & 3 deletions tooling/cli/templates/mobile/ios/project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,12 @@ targets:
ENABLE_BITCODE: false
ARCHS: [{{join ios-valid-archs}}]
VALID_ARCHS: {{~#each ios-valid-archs}} {{this}} {{/each}}
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)
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)
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)
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)
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)
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)
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES: true
EXCLUDED_ARCHS[sdk=iphonesimulator*]: arm64
EXCLUDED_ARCHS[sdk=iphoneos*]: arm64-sim x86_64
groups: [app]
dependencies:
- framework: lib{{app.lib-name}}.a
Expand Down

0 comments on commit 1a400c9

Please sign in to comment.