Skip to content

Commit 38f5db6

Browse files
committed
feat(codegen): fill app metadata in development Info.plist
1 parent 2616ede commit 38f5db6

File tree

17 files changed

+67
-10
lines changed

17 files changed

+67
-10
lines changed

.changes/dev-app-metadata.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"tauri-codegen": patch
3+
"tauri-macros": patch
4+
"tauri": patch
5+
---
6+
7+
Set the bundle name and app metadata in the Info.plist file in development mode.

.changes/dev-app-name.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

core/tauri-codegen/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ png = "0.17"
3131

3232
[target."cfg(target_os = \"macos\")".dependencies]
3333
plist = "1"
34+
time = { version = "0.3", features = [ "parsing", "formatting" ] }
3435

3536
[features]
3637
default = [ "compression" ]

core/tauri-codegen/src/context.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,17 @@ pub fn context_codegen(data: ContextData) -> Result<TokenStream, EmbeddedAssetsE
293293
plist::Value::Dictionary(Default::default())
294294
};
295295

296-
if let Some(dict) = info_plist.as_dictionary_mut() {
296+
if let Some(plist) = info_plist.as_dictionary_mut() {
297297
if let Some(product_name) = &config.package.product_name {
298-
dict.insert("CFBundleName".into(), product_name.clone().into());
298+
plist.insert("CFBundleName".into(), product_name.clone().into());
299+
}
300+
if let Some(version) = &config.package.version {
301+
plist.insert("CFBundleShortVersionString".into(), version.clone().into());
302+
}
303+
let format =
304+
time::format_description::parse("[year][month][day].[hour][minute][second]").unwrap();
305+
if let Ok(build_number) = time::OffsetDateTime::now_utc().format(&format) {
306+
plist.insert("CFBundleVersion".into(), build_number.into());
299307
}
300308
}
301309

examples/commands/tauri.conf.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
"beforeBuildCommand": "",
88
"withGlobalTauri": true
99
},
10+
"package": {
11+
"productName": "Commands",
12+
"version": "0.1.0"
13+
},
1014
"tauri": {
1115
"bundle": {
1216
"active": true,

examples/helloworld/tauri.conf.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
"beforeDevCommand": "",
77
"beforeBuildCommand": ""
88
},
9+
"package": {
10+
"productName": "Hello World",
11+
"version": "0.1.0"
12+
},
913
"tauri": {
1014
"bundle": {
1115
"active": true,

examples/isolation/tauri.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "../../tooling/cli/schema.json",
33
"package": {
4-
"productName": "isolation",
4+
"productName": "Isolation",
55
"version": "0.1.0"
66
},
77
"build": {

examples/multiwindow/tauri.conf.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
"devPath": ["index.html"],
66
"withGlobalTauri": true
77
},
8+
"package": {
9+
"productName": "Multi Window",
10+
"version": "0.1.0"
11+
},
812
"tauri": {
913
"bundle": {
1014
"active": true,

examples/navigation/tauri.conf.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
"beforeBuildCommand": "",
88
"withGlobalTauri": true
99
},
10+
"package": {
11+
"productName": "Navigation",
12+
"version": "0.1.0"
13+
},
1014
"tauri": {
1115
"bundle": {
1216
"active": true,

examples/parent-window/tauri.conf.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
"devPath": ["index.html"],
66
"withGlobalTauri": true
77
},
8+
"package": {
9+
"productName": "Parent Window",
10+
"version": "0.1.0"
11+
},
812
"tauri": {
913
"bundle": {
1014
"active": true,

0 commit comments

Comments
 (0)