Skip to content

Commit

Permalink
feat(codegen): fill app metadata in development Info.plist
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed Jun 21, 2022
1 parent 2616ede commit 38f5db6
Show file tree
Hide file tree
Showing 17 changed files with 67 additions and 10 deletions.
7 changes: 7 additions & 0 deletions .changes/dev-app-metadata.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"tauri-codegen": patch
"tauri-macros": patch
"tauri": patch
---

Set the bundle name and app metadata in the Info.plist file in development mode.
7 changes: 0 additions & 7 deletions .changes/dev-app-name.md

This file was deleted.

1 change: 1 addition & 0 deletions core/tauri-codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ png = "0.17"

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

[features]
default = [ "compression" ]
Expand Down
12 changes: 10 additions & 2 deletions core/tauri-codegen/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,17 @@ pub fn context_codegen(data: ContextData) -> Result<TokenStream, EmbeddedAssetsE
plist::Value::Dictionary(Default::default())
};

if let Some(dict) = info_plist.as_dictionary_mut() {
if let Some(plist) = info_plist.as_dictionary_mut() {
if let Some(product_name) = &config.package.product_name {
dict.insert("CFBundleName".into(), product_name.clone().into());
plist.insert("CFBundleName".into(), product_name.clone().into());
}
if let Some(version) = &config.package.version {
plist.insert("CFBundleShortVersionString".into(), version.clone().into());
}
let format =
time::format_description::parse("[year][month][day].[hour][minute][second]").unwrap();
if let Ok(build_number) = time::OffsetDateTime::now_utc().format(&format) {
plist.insert("CFBundleVersion".into(), build_number.into());
}
}

Expand Down
4 changes: 4 additions & 0 deletions examples/commands/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"beforeBuildCommand": "",
"withGlobalTauri": true
},
"package": {
"productName": "Commands",
"version": "0.1.0"
},
"tauri": {
"bundle": {
"active": true,
Expand Down
4 changes: 4 additions & 0 deletions examples/helloworld/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
"beforeDevCommand": "",
"beforeBuildCommand": ""
},
"package": {
"productName": "Hello World",
"version": "0.1.0"
},
"tauri": {
"bundle": {
"active": true,
Expand Down
2 changes: 1 addition & 1 deletion examples/isolation/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "../../tooling/cli/schema.json",
"package": {
"productName": "isolation",
"productName": "Isolation",
"version": "0.1.0"
},
"build": {
Expand Down
4 changes: 4 additions & 0 deletions examples/multiwindow/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"devPath": ["index.html"],
"withGlobalTauri": true
},
"package": {
"productName": "Multi Window",
"version": "0.1.0"
},
"tauri": {
"bundle": {
"active": true,
Expand Down
4 changes: 4 additions & 0 deletions examples/navigation/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"beforeBuildCommand": "",
"withGlobalTauri": true
},
"package": {
"productName": "Navigation",
"version": "0.1.0"
},
"tauri": {
"bundle": {
"active": true,
Expand Down
4 changes: 4 additions & 0 deletions examples/parent-window/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"devPath": ["index.html"],
"withGlobalTauri": true
},
"package": {
"productName": "Parent Window",
"version": "0.1.0"
},
"tauri": {
"bundle": {
"active": true,
Expand Down
4 changes: 4 additions & 0 deletions examples/resources/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"beforeBuildCommand": "",
"withGlobalTauri": true
},
"package": {
"productName": "Resources",
"version": "0.1.0"
},
"tauri": {
"bundle": {
"active": true,
Expand Down
4 changes: 4 additions & 0 deletions examples/sidecar/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"beforeBuildCommand": "yarn package",
"withGlobalTauri": true
},
"package": {
"productName": "Sidecar",
"version": "0.1.0"
},
"tauri": {
"bundle": {
"active": true,
Expand Down
4 changes: 4 additions & 0 deletions examples/splashscreen/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"devPath": "dist",
"withGlobalTauri": true
},
"package": {
"productName": "Splashscreen",
"version": "0.1.0"
},
"tauri": {
"bundle": {
"active": true,
Expand Down
4 changes: 4 additions & 0 deletions examples/state/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"beforeBuildCommand": "",
"withGlobalTauri": true
},
"package": {
"productName": "State",
"version": "0.1.0"
},
"tauri": {
"bundle": {
"active": true,
Expand Down
4 changes: 4 additions & 0 deletions examples/streaming/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"beforeBuildCommand": "",
"withGlobalTauri": true
},
"package": {
"productName": "Streaming",
"version": "0.1.0"
},
"tauri": {
"bundle": {
"active": true,
Expand Down
4 changes: 4 additions & 0 deletions examples/tauri-dynamic-lib/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
"beforeDevCommand": "",
"beforeBuildCommand": ""
},
"package": {
"productName": "Dynamic Lib",
"version": "0.1.0"
},
"tauri": {
"bundle": {
"active": true,
Expand Down
4 changes: 4 additions & 0 deletions examples/updater/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
"beforeDevCommand": "",
"beforeBuildCommand": ""
},
"package": {
"productName": "Updater",
"version": "0.1.0"
},
"tauri": {
"bundle": {
"active": true,
Expand Down

0 comments on commit 38f5db6

Please sign in to comment.