Skip to content

Commit

Permalink
feat(cli): codesign on iOS is optional for the simulator (#8910)
Browse files Browse the repository at this point in the history
* feat(cli): codesign on iOS is optional for the simulator

* cargo-mobile2 0.10
  • Loading branch information
lucasfernog authored Feb 21, 2024
1 parent 3fb414b commit a029b9f
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 67 deletions.
6 changes: 6 additions & 0 deletions .changes/ios-signing-optional.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@tauri-apps/cli": patch:enhance
"tauri-cli": patch:enhance
---

Setting up code signing is no longer required on iOS when using the simulator.
16 changes: 8 additions & 8 deletions examples/api/src-tauri/Cargo.lock

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

23 changes: 7 additions & 16 deletions tooling/cli/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 tooling/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ name = "cargo-tauri"
path = "src/main.rs"

[dependencies]
cargo-mobile2 = { version = "0.8", default-features = false }
cargo-mobile2 = { version = "0.10", default-features = false }
jsonrpsee = { version = "0.20", features = [ "server" ] }
jsonrpsee-core = "0.20"
jsonrpsee-client-transport = { version = "0.20", features = [ "ws" ] }
Expand Down
38 changes: 3 additions & 35 deletions tooling/cli/src/mobile/ios/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use super::{
configure_cargo, device_prompt, ensure_init, env, get_app, get_config, inject_assets,
merge_plist, open_and_wait, setup_dev_config, MobileTarget, APPLE_DEVELOPMENT_TEAM_ENV_VAR_NAME,
merge_plist, open_and_wait, setup_dev_config, MobileTarget,
};
use crate::{
dev::Options as DevOptions,
Expand All @@ -21,14 +21,13 @@ use clap::{ArgAction, Parser};

use anyhow::Context;
use cargo_mobile2::{
apple::{config::Config as AppleConfig, device::Device, teams::find_development_teams},
apple::{config::Config as AppleConfig, device::Device},
config::app::App,
env::Env,
opts::{NoiseLevel, Profile},
};
use dialoguer::{theme::ColorfulTheme, Select};

use std::env::{set_current_dir, set_var, var_os};
use std::env::set_current_dir;

#[derive(Debug, Clone, Parser)]
#[clap(
Expand Down Expand Up @@ -98,37 +97,6 @@ pub fn command(options: Options, noise_level: NoiseLevel) -> Result<()> {
}

fn run_command(options: Options, noise_level: NoiseLevel) -> Result<()> {
if var_os(APPLE_DEVELOPMENT_TEAM_ENV_VAR_NAME).is_none() {
if let Ok(teams) = find_development_teams() {
let index = match teams.len() {
0 => None,
1 => Some(0),
_ => {
let index = Select::with_theme(&ColorfulTheme::default())
.items(
&teams
.iter()
.map(|t| format!("{} (ID: {})", t.name, t.id))
.collect::<Vec<String>>(),
)
.default(0)
.interact()?;
Some(index)
}
};
if let Some(index) = index {
let team = teams.get(index).unwrap();
log::info!(
"Using development team `{}`. To make this permanent, set the `{}` environment variable to `{}`",
team.name,
APPLE_DEVELOPMENT_TEAM_ENV_VAR_NAME,
team.id
);
set_var(APPLE_DEVELOPMENT_TEAM_ENV_VAR_NAME, &team.id);
}
}
}

let env = env()?;
let device = if options.open {
None
Expand Down
13 changes: 6 additions & 7 deletions tooling/cli/src/mobile/ios/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ use std::{
env::set_var,
fs::create_dir_all,
path::{Path, PathBuf},
process::exit,
thread::sleep,
time::Duration,
};
Expand Down Expand Up @@ -114,17 +113,17 @@ pub fn get_config(
development_team: std::env::var(APPLE_DEVELOPMENT_TEAM_ENV_VAR_NAME)
.ok()
.or_else(|| config.bundle.ios.development_team.clone())
.unwrap_or_else(|| {
.or_else(|| {
let teams = find_development_teams().unwrap_or_default();
match teams.len() {
0 => {
log::error!("No code signing certificates found. You must add one and set the certificate development team ID on the `bundle > iOS > developmentTeam` config value or the `{APPLE_DEVELOPMENT_TEAM_ENV_VAR_NAME}` environment variable. To list the available certificates, run `tauri info`.");
exit(1);
log::warn!("No code signing certificates found. You must add one and set the certificate development team ID on the `bundle > iOS > developmentTeam` config value or the `{APPLE_DEVELOPMENT_TEAM_ENV_VAR_NAME}` environment variable. To list the available certificates, run `tauri info`.");
None
}
1 => teams.first().unwrap().id.clone(),
1 => Some(teams.first().unwrap().id.clone()),
_ => {
log::error!("You must set the code signing certificate development team ID on the `bundle > iOS > developmentTeam` config value or the `{APPLE_DEVELOPMENT_TEAM_ENV_VAR_NAME}` environment variable. Available certificates: {}", teams.iter().map(|t| format!("{} (ID: {})", t.name, t.id)).collect::<Vec<String>>().join(", "));
exit(1);
log::warn!("You must set the code signing certificate development team ID on the `bundle > iOS > developmentTeam` config value or the `{APPLE_DEVELOPMENT_TEAM_ENV_VAR_NAME}` environment variable. Available certificates: {}", teams.iter().map(|t| format!("{} (ID: {})", t.name, t.id)).collect::<Vec<String>>().join(", "));
None
}
}
}),
Expand Down
2 changes: 2 additions & 0 deletions tooling/cli/templates/mobile/ios/project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ settingGroups:
base:
PRODUCT_NAME: {{app.stylized-name}}
PRODUCT_BUNDLE_IDENTIFIER: {{reverse-domain app.domain}}.{{app.name}}
{{#if apple.development-team}}
DEVELOPMENT_TEAM: {{apple.development-team}}
{{/if}}
targetTemplates:
app:
type: application
Expand Down

0 comments on commit a029b9f

Please sign in to comment.