Skip to content

Commit 02c00ab

Browse files
authored
feat(core): add config for the minimum iOS version (#10495)
* feat(core): add config for the minimum iOS version * revert api exapmle
1 parent 5be7607 commit 02c00ab

File tree

7 files changed

+60
-12
lines changed

7 files changed

+60
-12
lines changed

.changes/min-ios-version.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"tauri-utils": patch:feat
3+
"tauri-cli": patch:feat
4+
"@tauri-apps/cli": patch:feat
5+
---
6+
7+
Added `bundle > ios > minimumSystemVersion` configuration option.

core/tauri-build/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,13 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
601601
}
602602
}
603603

604+
if target_triple.contains("ios") {
605+
println!(
606+
"cargo:rustc-env=IPHONEOS_DEPLOYMENT_TARGET={}",
607+
config.bundle.ios.minimum_system_version
608+
);
609+
}
610+
604611
if target_triple.contains("windows") {
605612
use semver::Version;
606613
use tauri_winres::{VersionInfo, WindowsResource};

core/tauri-config-schema/schema.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@
7474
"minSdkVersion": 24
7575
},
7676
"createUpdaterArtifacts": false,
77-
"iOS": {},
77+
"iOS": {
78+
"minimumSystemVersion": ""
79+
},
7880
"icon": [],
7981
"linux": {
8082
"appimage": {
@@ -1712,7 +1714,9 @@
17121714
},
17131715
"iOS": {
17141716
"description": "iOS configuration.",
1715-
"default": {},
1717+
"default": {
1718+
"minimumSystemVersion": ""
1719+
},
17161720
"allOf": [
17171721
{
17181722
"$ref": "#/definitions/IosConfig"
@@ -2912,6 +2916,11 @@
29122916
"string",
29132917
"null"
29142918
]
2919+
},
2920+
"minimumSystemVersion": {
2921+
"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.",
2922+
"default": "13.0",
2923+
"type": "string"
29152924
}
29162925
},
29172926
"additionalProperties": false

core/tauri-utils/src/config.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -536,13 +536,13 @@ fn dmg_application_folder_position() -> Position {
536536
Position { x: 480, y: 170 }
537537
}
538538

539-
fn de_minimum_system_version<'de, D>(deserializer: D) -> Result<Option<String>, D::Error>
539+
fn de_macos_minimum_system_version<'de, D>(deserializer: D) -> Result<Option<String>, D::Error>
540540
where
541541
D: Deserializer<'de>,
542542
{
543543
let version = Option::<String>::deserialize(deserializer)?;
544544
match version {
545-
Some(v) if v.is_empty() => Ok(minimum_system_version()),
545+
Some(v) if v.is_empty() => Ok(macos_minimum_system_version()),
546546
e => Ok(e),
547547
}
548548
}
@@ -569,8 +569,8 @@ pub struct MacConfig {
569569
///
570570
/// An empty string is considered an invalid value so the default value is used.
571571
#[serde(
572-
deserialize_with = "de_minimum_system_version",
573-
default = "minimum_system_version",
572+
deserialize_with = "de_macos_minimum_system_version",
573+
default = "macos_minimum_system_version",
574574
alias = "minimum-system-version"
575575
)]
576576
pub minimum_system_version: Option<String>,
@@ -601,7 +601,7 @@ impl Default for MacConfig {
601601
Self {
602602
frameworks: None,
603603
files: HashMap::new(),
604-
minimum_system_version: minimum_system_version(),
604+
minimum_system_version: macos_minimum_system_version(),
605605
exception_domain: None,
606606
signing_identity: None,
607607
hardened_runtime: true,
@@ -612,10 +612,14 @@ impl Default for MacConfig {
612612
}
613613
}
614614

615-
fn minimum_system_version() -> Option<String> {
615+
fn macos_minimum_system_version() -> Option<String> {
616616
Some("10.13".into())
617617
}
618618

619+
fn ios_minimum_system_version() -> String {
620+
"13.0".into()
621+
}
622+
619623
/// Configuration for a target language for the WiX build.
620624
///
621625
/// See more: <https://tauri.app/v1/api/config#wixlanguageconfig>
@@ -1897,6 +1901,14 @@ pub struct IosConfig {
18971901
/// The `APPLE_DEVELOPMENT_TEAM` environment variable can be set to overwrite it.
18981902
#[serde(alias = "development-team")]
18991903
pub development_team: Option<String>,
1904+
/// A version string indicating the minimum iOS version that the bundled application supports. Defaults to `13.0`.
1905+
///
1906+
/// Maps to the IPHONEOS_DEPLOYMENT_TARGET value.
1907+
#[serde(
1908+
alias = "minimum-system-version",
1909+
default = "ios_minimum_system_version"
1910+
)]
1911+
pub minimum_system_version: String,
19001912
}
19011913

19021914
/// General configuration for the iOS target.

tooling/cli/schema.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@
7474
"minSdkVersion": 24
7575
},
7676
"createUpdaterArtifacts": false,
77-
"iOS": {},
77+
"iOS": {
78+
"minimumSystemVersion": ""
79+
},
7880
"icon": [],
7981
"linux": {
8082
"appimage": {
@@ -1712,7 +1714,9 @@
17121714
},
17131715
"iOS": {
17141716
"description": "iOS configuration.",
1715-
"default": {},
1717+
"default": {
1718+
"minimumSystemVersion": ""
1719+
},
17161720
"allOf": [
17171721
{
17181722
"$ref": "#/definitions/IosConfig"
@@ -2912,6 +2916,11 @@
29122916
"string",
29132917
"null"
29142918
]
2919+
},
2920+
"minimumSystemVersion": {
2921+
"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.",
2922+
"default": "13.0",
2923+
"type": "string"
29152924
}
29162925
},
29172926
"additionalProperties": false

tooling/cli/src/interface/rust.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ impl Interface for Rust {
149149
std::env::set_var("MACOSX_DEPLOYMENT_TARGET", minimum_system_version);
150150
}
151151

152+
std::env::set_var(
153+
"IPHONEOS_DEPLOYMENT_TARGET",
154+
&config.bundle.ios.minimum_system_version,
155+
);
156+
152157
let app_settings = RustAppSettings::new(config, manifest, target)?;
153158

154159
Ok(Self {

tooling/cli/src/mobile/ios/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ pub(crate) mod project;
4646
mod xcode_script;
4747

4848
pub const APPLE_DEVELOPMENT_TEAM_ENV_VAR_NAME: &str = "APPLE_DEVELOPMENT_TEAM";
49-
const TARGET_IOS_VERSION: &str = "13.0";
5049

5150
#[derive(Parser)]
5251
#[clap(
@@ -136,7 +135,7 @@ pub fn get_config(
136135
ios_features: ios_options.features.clone(),
137136
bundle_version: tauri_config.version.clone(),
138137
bundle_version_short: tauri_config.version.clone(),
139-
ios_version: Some(TARGET_IOS_VERSION.into()),
138+
ios_version: Some(tauri_config.bundle.ios.minimum_system_version.clone()),
140139
..Default::default()
141140
};
142141
let config = AppleConfig::from_raw(app.clone(), Some(raw)).unwrap();

0 commit comments

Comments
 (0)