Skip to content

Commit

Permalink
fix(cli): automatic signing for iOS on CI (#10851)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog authored Aug 31, 2024
1 parent 5ec7445 commit 5af1f5d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .changes/fix-ios-signing-api-key.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"tauri-cli": patch:bug
"@tauri-apps/cli": patch:bug
---

Fixes `ios build` failing to build iOS app in CI when using an API key for automatic signing.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/tauri-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ name = "cargo-tauri"
path = "src/main.rs"

[target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\", target_os = \"windows\", target_os = \"macos\"))".dependencies]
cargo-mobile2 = { version = "0.15.1", default-features = false }
cargo-mobile2 = { version = "0.16", default-features = false }

[dependencies]
jsonrpsee = { version = "0.24", features = ["server"] }
Expand Down
24 changes: 19 additions & 5 deletions crates/tauri-cli/src/mobile/ios/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use anyhow::Context;
use cargo_mobile2::{
apple::{
config::Config as AppleConfig,
target::{ExportConfig, Target},
target::{BuildConfig, ExportConfig, Target},
},
env::Env,
opts::{NoiseLevel, Profile},
Expand Down Expand Up @@ -299,11 +299,25 @@ fn run_build(
app_version.push_extra(build_number);
}

target.build(config, env, NoiseLevel::FranklyQuitePedantic, profile)?;
let credentials = auth_credentials_from_env()?;

let mut build_config = BuildConfig::new().allow_provisioning_updates();
if let Some(credentials) = &credentials {
build_config = build_config.authentication_credentials(credentials.clone());
}

target.build(
config,
env,
NoiseLevel::FranklyQuitePedantic,
profile,
build_config,
)?;

target.archive(config, env, noise_level, profile, Some(app_version))?;

let mut export_config = ExportConfig::new().allow_provisioning_updates();
if let Some(credentials) = auth_credentials_from_env()? {
if let Some(credentials) = credentials {
export_config = export_config.authentication_credentials(credentials);
}

Expand All @@ -327,14 +341,14 @@ fn run_build(
Ok(handle)
}

fn auth_credentials_from_env() -> Result<Option<cargo_mobile2::apple::target::AuthCredentials>> {
fn auth_credentials_from_env() -> Result<Option<cargo_mobile2::apple::AuthCredentials>> {
match (
var("APPLE_API_KEY"),
var("APPLE_API_ISSUER"),
var_os("APPLE_API_KEY_PATH").map(PathBuf::from),
) {
(Ok(key_id), Ok(key_issuer_id), Some(key_path)) => {
Ok(Some(cargo_mobile2::apple::target::AuthCredentials {
Ok(Some(cargo_mobile2::apple::AuthCredentials {
key_path,
key_id,
key_issuer_id,
Expand Down

0 comments on commit 5af1f5d

Please sign in to comment.