Selaa lähdekoodia

feat(codegen): fill app metadata in development Info.plist

Lucas Nogueira 3 vuotta sitten
vanhempi
sitoutus
38f5db6e6a

+ 7 - 0
.changes/dev-app-metadata.md

@@ -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.

+ 0 - 7
.changes/dev-app-name.md

@@ -1,7 +0,0 @@
----
-"tauri-codegen": patch
-"tauri-macros": patch
-"tauri": patch
----
-
-Set the bundle name in the Info.plist file in development mode.

+ 1 - 0
core/tauri-codegen/Cargo.toml

@@ -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" ]

+ 10 - 2
core/tauri-codegen/src/context.rs

@@ -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());
         }
       }
 

+ 4 - 0
examples/commands/tauri.conf.json

@@ -7,6 +7,10 @@
     "beforeBuildCommand": "",
     "withGlobalTauri": true
   },
+  "package": {
+    "productName": "Commands",
+    "version": "0.1.0"
+  },
   "tauri": {
     "bundle": {
       "active": true,

+ 4 - 0
examples/helloworld/tauri.conf.json

@@ -6,6 +6,10 @@
     "beforeDevCommand": "",
     "beforeBuildCommand": ""
   },
+  "package": {
+    "productName": "Hello World",
+    "version": "0.1.0"
+  },
   "tauri": {
     "bundle": {
       "active": true,

+ 1 - 1
examples/isolation/tauri.conf.json

@@ -1,7 +1,7 @@
 {
   "$schema": "../../tooling/cli/schema.json",
   "package": {
-    "productName": "isolation",
+    "productName": "Isolation",
     "version": "0.1.0"
   },
   "build": {

+ 4 - 0
examples/multiwindow/tauri.conf.json

@@ -5,6 +5,10 @@
     "devPath": ["index.html"],
     "withGlobalTauri": true
   },
+  "package": {
+    "productName": "Multi Window",
+    "version": "0.1.0"
+  },
   "tauri": {
     "bundle": {
       "active": true,

+ 4 - 0
examples/navigation/tauri.conf.json

@@ -7,6 +7,10 @@
     "beforeBuildCommand": "",
     "withGlobalTauri": true
   },
+  "package": {
+    "productName": "Navigation",
+    "version": "0.1.0"
+  },
   "tauri": {
     "bundle": {
       "active": true,

+ 4 - 0
examples/parent-window/tauri.conf.json

@@ -5,6 +5,10 @@
     "devPath": ["index.html"],
     "withGlobalTauri": true
   },
+  "package": {
+    "productName": "Parent Window",
+    "version": "0.1.0"
+  },
   "tauri": {
     "bundle": {
       "active": true,

+ 4 - 0
examples/resources/src-tauri/tauri.conf.json

@@ -7,6 +7,10 @@
     "beforeBuildCommand": "",
     "withGlobalTauri": true
   },
+  "package": {
+    "productName": "Resources",
+    "version": "0.1.0"
+  },
   "tauri": {
     "bundle": {
       "active": true,

+ 4 - 0
examples/sidecar/src-tauri/tauri.conf.json

@@ -7,6 +7,10 @@
     "beforeBuildCommand": "yarn package",
     "withGlobalTauri": true
   },
+  "package": {
+    "productName": "Sidecar",
+    "version": "0.1.0"
+  },
   "tauri": {
     "bundle": {
       "active": true,

+ 4 - 0
examples/splashscreen/tauri.conf.json

@@ -5,6 +5,10 @@
     "devPath": "dist",
     "withGlobalTauri": true
   },
+  "package": {
+    "productName": "Splashscreen",
+    "version": "0.1.0"
+  },
   "tauri": {
     "bundle": {
       "active": true,

+ 4 - 0
examples/state/tauri.conf.json

@@ -7,6 +7,10 @@
     "beforeBuildCommand": "",
     "withGlobalTauri": true
   },
+  "package": {
+    "productName": "State",
+    "version": "0.1.0"
+  },
   "tauri": {
     "bundle": {
       "active": true,

+ 4 - 0
examples/streaming/tauri.conf.json

@@ -7,6 +7,10 @@
     "beforeBuildCommand": "",
     "withGlobalTauri": true
   },
+  "package": {
+    "productName": "Streaming",
+    "version": "0.1.0"
+  },
   "tauri": {
     "bundle": {
       "active": true,

+ 4 - 0
examples/tauri-dynamic-lib/src-tauri/tauri.conf.json

@@ -6,6 +6,10 @@
     "beforeDevCommand": "",
     "beforeBuildCommand": ""
   },
+  "package": {
+    "productName": "Dynamic Lib",
+    "version": "0.1.0"
+  },
   "tauri": {
     "bundle": {
       "active": true,

+ 4 - 0
examples/updater/src-tauri/tauri.conf.json

@@ -6,6 +6,10 @@
     "beforeDevCommand": "",
     "beforeBuildCommand": ""
   },
+  "package": {
+    "productName": "Updater",
+    "version": "0.1.0"
+  },
   "tauri": {
     "bundle": {
       "active": true,