|
@@ -30,6 +30,7 @@ use cargo_mobile2::{
|
|
|
opts::{NoiseLevel, Profile},
|
|
|
target::{call_for_targets_with_fallback, TargetInvalid, TargetTrait},
|
|
|
};
|
|
|
+use rand::distributions::{Alphanumeric, DistString};
|
|
|
|
|
|
use std::{
|
|
|
env::{set_current_dir, var, var_os},
|
|
@@ -240,7 +241,7 @@ pub fn command(options: Options, noise_level: NoiseLevel) -> Result<()> {
|
|
|
options,
|
|
|
build_options,
|
|
|
tauri_config,
|
|
|
- &config,
|
|
|
+ &mut config,
|
|
|
&mut env,
|
|
|
noise_level,
|
|
|
)?;
|
|
@@ -258,7 +259,7 @@ fn run_build(
|
|
|
options: Options,
|
|
|
mut build_options: BuildOptions,
|
|
|
tauri_config: ConfigHandle,
|
|
|
- config: &AppleConfig,
|
|
|
+ config: &mut AppleConfig,
|
|
|
env: &mut Env,
|
|
|
noise_level: NoiseLevel,
|
|
|
) -> Result<OptionsHandle> {
|
|
@@ -305,30 +306,31 @@ fn run_build(
|
|
|
}
|
|
|
|
|
|
let credentials = auth_credentials_from_env()?;
|
|
|
+ let skip_signing = credentials.is_some();
|
|
|
|
|
|
- let mut build_config = BuildConfig::new()
|
|
|
- .allow_provisioning_updates()
|
|
|
- .skip_codesign();
|
|
|
+ let mut build_config = BuildConfig::new().allow_provisioning_updates();
|
|
|
if let Some(credentials) = &credentials {
|
|
|
- build_config = build_config.authentication_credentials(credentials.clone());
|
|
|
+ build_config = build_config
|
|
|
+ .authentication_credentials(credentials.clone())
|
|
|
+ .skip_codesign();
|
|
|
}
|
|
|
|
|
|
target.build(config, env, noise_level, profile, build_config)?;
|
|
|
|
|
|
+ let mut archive_config = ArchiveConfig::new();
|
|
|
+ if skip_signing {
|
|
|
+ archive_config = archive_config.skip_codesign();
|
|
|
+ }
|
|
|
+
|
|
|
target.archive(
|
|
|
config,
|
|
|
env,
|
|
|
noise_level,
|
|
|
profile,
|
|
|
Some(app_version),
|
|
|
- ArchiveConfig::new().skip_codesign(),
|
|
|
+ archive_config,
|
|
|
)?;
|
|
|
|
|
|
- let mut export_config = ExportConfig::new().allow_provisioning_updates();
|
|
|
- if let Some(credentials) = credentials {
|
|
|
- export_config = export_config.authentication_credentials(credentials);
|
|
|
- }
|
|
|
-
|
|
|
let out_dir = config.export_dir().join(target.arch);
|
|
|
|
|
|
if target.sdk == "iphonesimulator" {
|
|
@@ -346,6 +348,51 @@ fn run_build(
|
|
|
fs::rename(&app_path, &path)?;
|
|
|
out_files.push(path);
|
|
|
} else {
|
|
|
+ // if we skipped code signing, we do not have the entitlements applied to our exported IPA
|
|
|
+ // we must force sign the app binary with a dummy certificate just to preserve the entitlements
|
|
|
+ // target.export() will sign it with an actual certificate for us
|
|
|
+ if skip_signing {
|
|
|
+ let password = Alphanumeric.sample_string(&mut rand::thread_rng(), 16);
|
|
|
+ let certificate = tauri_macos_sign::certificate::generate_self_signed(
|
|
|
+ tauri_macos_sign::certificate::SelfSignedCertificateRequest {
|
|
|
+ algorithm: "rsa".to_string(),
|
|
|
+ profile: tauri_macos_sign::certificate::CertificateProfile::AppleDistribution,
|
|
|
+ team_id: "unset".to_string(),
|
|
|
+ person_name: "Tauri".to_string(),
|
|
|
+ country_name: "NL".to_string(),
|
|
|
+ validity_days: 365,
|
|
|
+ password: password.clone(),
|
|
|
+ },
|
|
|
+ )?;
|
|
|
+ let tmp_dir = tempfile::tempdir()?;
|
|
|
+ let cert_path = tmp_dir.path().join("cert.p12");
|
|
|
+ std::fs::write(&cert_path, certificate)?;
|
|
|
+ let self_signed_cert_keychain =
|
|
|
+ tauri_macos_sign::Keychain::with_certificate_file(&cert_path, &password.into())?;
|
|
|
+
|
|
|
+ let app_dir = config
|
|
|
+ .export_dir()
|
|
|
+ .join(format!("{}.xcarchive", config.scheme()))
|
|
|
+ .join("Products/Applications")
|
|
|
+ .join(format!("{}.app", config.app().stylized_name()));
|
|
|
+
|
|
|
+ self_signed_cert_keychain.sign(
|
|
|
+ &app_dir.join(config.app().stylized_name()),
|
|
|
+ Some(
|
|
|
+ &config
|
|
|
+ .project_dir()
|
|
|
+ .join(config.scheme())
|
|
|
+ .join(format!("{}.entitlements", config.scheme())),
|
|
|
+ ),
|
|
|
+ false,
|
|
|
+ )?;
|
|
|
+ }
|
|
|
+
|
|
|
+ let mut export_config = ExportConfig::new().allow_provisioning_updates();
|
|
|
+ if let Some(credentials) = &credentials {
|
|
|
+ export_config = export_config.authentication_credentials(credentials.clone());
|
|
|
+ }
|
|
|
+
|
|
|
target.export(config, env, noise_level, export_config)?;
|
|
|
|
|
|
if let Ok(ipa_path) = config.ipa_path() {
|