Skip to content

Commit

Permalink
feat(core): add config for the minimum iOS version (#10495)
Browse files Browse the repository at this point in the history
* feat(core): add config for the minimum iOS version

* revert api exapmle
  • Loading branch information
lucasfernog authored Aug 7, 2024
1 parent 5be7607 commit 02c00ab
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 12 deletions.
7 changes: 7 additions & 0 deletions .changes/min-ios-version.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"tauri-utils": patch:feat
"tauri-cli": patch:feat
"@tauri-apps/cli": patch:feat
---

Added `bundle > ios > minimumSystemVersion` configuration option.
7 changes: 7 additions & 0 deletions core/tauri-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,13 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
}
}

if target_triple.contains("ios") {
println!(
"cargo:rustc-env=IPHONEOS_DEPLOYMENT_TARGET={}",
config.bundle.ios.minimum_system_version
);
}

if target_triple.contains("windows") {
use semver::Version;
use tauri_winres::{VersionInfo, WindowsResource};
Expand Down
13 changes: 11 additions & 2 deletions core/tauri-config-schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@
"minSdkVersion": 24
},
"createUpdaterArtifacts": false,
"iOS": {},
"iOS": {
"minimumSystemVersion": ""
},
"icon": [],
"linux": {
"appimage": {
Expand Down Expand Up @@ -1712,7 +1714,9 @@
},
"iOS": {
"description": "iOS configuration.",
"default": {},
"default": {
"minimumSystemVersion": ""
},
"allOf": [
{
"$ref": "#/definitions/IosConfig"
Expand Down Expand Up @@ -2912,6 +2916,11 @@
"string",
"null"
]
},
"minimumSystemVersion": {
"description": "A version string indicating the minimum iOS version that the bundled application supports. Defaults to `13.0`.\n\n Maps to the IPHONEOS_DEPLOYMENT_TARGET value.",
"default": "13.0",
"type": "string"
}
},
"additionalProperties": false
Expand Down
24 changes: 18 additions & 6 deletions core/tauri-utils/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,13 +536,13 @@ fn dmg_application_folder_position() -> Position {
Position { x: 480, y: 170 }
}

fn de_minimum_system_version<'de, D>(deserializer: D) -> Result<Option<String>, D::Error>
fn de_macos_minimum_system_version<'de, D>(deserializer: D) -> Result<Option<String>, D::Error>
where
D: Deserializer<'de>,
{
let version = Option::<String>::deserialize(deserializer)?;
match version {
Some(v) if v.is_empty() => Ok(minimum_system_version()),
Some(v) if v.is_empty() => Ok(macos_minimum_system_version()),
e => Ok(e),
}
}
Expand All @@ -569,8 +569,8 @@ pub struct MacConfig {
///
/// An empty string is considered an invalid value so the default value is used.
#[serde(
deserialize_with = "de_minimum_system_version",
default = "minimum_system_version",
deserialize_with = "de_macos_minimum_system_version",
default = "macos_minimum_system_version",
alias = "minimum-system-version"
)]
pub minimum_system_version: Option<String>,
Expand Down Expand Up @@ -601,7 +601,7 @@ impl Default for MacConfig {
Self {
frameworks: None,
files: HashMap::new(),
minimum_system_version: minimum_system_version(),
minimum_system_version: macos_minimum_system_version(),
exception_domain: None,
signing_identity: None,
hardened_runtime: true,
Expand All @@ -612,10 +612,14 @@ impl Default for MacConfig {
}
}

fn minimum_system_version() -> Option<String> {
fn macos_minimum_system_version() -> Option<String> {
Some("10.13".into())
}

fn ios_minimum_system_version() -> String {
"13.0".into()
}

/// Configuration for a target language for the WiX build.
///
/// See more: <https://tauri.app/v1/api/config#wixlanguageconfig>
Expand Down Expand Up @@ -1897,6 +1901,14 @@ pub struct IosConfig {
/// The `APPLE_DEVELOPMENT_TEAM` environment variable can be set to overwrite it.
#[serde(alias = "development-team")]
pub development_team: Option<String>,
/// A version string indicating the minimum iOS version that the bundled application supports. Defaults to `13.0`.
///
/// Maps to the IPHONEOS_DEPLOYMENT_TARGET value.
#[serde(
alias = "minimum-system-version",
default = "ios_minimum_system_version"
)]
pub minimum_system_version: String,
}

/// General configuration for the iOS target.
Expand Down
13 changes: 11 additions & 2 deletions tooling/cli/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@
"minSdkVersion": 24
},
"createUpdaterArtifacts": false,
"iOS": {},
"iOS": {
"minimumSystemVersion": ""
},
"icon": [],
"linux": {
"appimage": {
Expand Down Expand Up @@ -1712,7 +1714,9 @@
},
"iOS": {
"description": "iOS configuration.",
"default": {},
"default": {
"minimumSystemVersion": ""
},
"allOf": [
{
"$ref": "#/definitions/IosConfig"
Expand Down Expand Up @@ -2912,6 +2916,11 @@
"string",
"null"
]
},
"minimumSystemVersion": {
"description": "A version string indicating the minimum iOS version that the bundled application supports. Defaults to `13.0`.\n\n Maps to the IPHONEOS_DEPLOYMENT_TARGET value.",
"default": "13.0",
"type": "string"
}
},
"additionalProperties": false
Expand Down
5 changes: 5 additions & 0 deletions tooling/cli/src/interface/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ impl Interface for Rust {
std::env::set_var("MACOSX_DEPLOYMENT_TARGET", minimum_system_version);
}

std::env::set_var(
"IPHONEOS_DEPLOYMENT_TARGET",
&config.bundle.ios.minimum_system_version,
);

let app_settings = RustAppSettings::new(config, manifest, target)?;

Ok(Self {
Expand Down
3 changes: 1 addition & 2 deletions tooling/cli/src/mobile/ios/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ pub(crate) mod project;
mod xcode_script;

pub const APPLE_DEVELOPMENT_TEAM_ENV_VAR_NAME: &str = "APPLE_DEVELOPMENT_TEAM";
const TARGET_IOS_VERSION: &str = "13.0";

#[derive(Parser)]
#[clap(
Expand Down Expand Up @@ -136,7 +135,7 @@ pub fn get_config(
ios_features: ios_options.features.clone(),
bundle_version: tauri_config.version.clone(),
bundle_version_short: tauri_config.version.clone(),
ios_version: Some(TARGET_IOS_VERSION.into()),
ios_version: Some(tauri_config.bundle.ios.minimum_system_version.clone()),
..Default::default()
};
let config = AppleConfig::from_raw(app.clone(), Some(raw)).unwrap();
Expand Down

0 comments on commit 02c00ab

Please sign in to comment.