Skip to content

Commit b3a3afc

Browse files
authored
feat(core): detect android and ios platform configuration files (#4997)
1 parent 3d992a8 commit b3a3afc

4 files changed

Lines changed: 26 additions & 7 deletions

File tree

.changes/mobile-config.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri-utils": minor
3+
---
4+
5+
Parse `android` and `ios` Tauri configuration files.

core/tauri-utils/src/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2616,8 +2616,8 @@ impl PackageConfig {
26162616
///
26172617
/// In addition to the default configuration file, Tauri can
26182618
/// read a platform-specific configuration from `tauri.linux.conf.json`,
2619-
/// `tauri.windows.conf.json`, and `tauri.macos.conf.json`
2620-
/// (or `Tauri.linux.toml`, `Tauri.windows.toml` and `Tauri.macos.toml` if the `Tauri.toml` format is used),
2619+
/// `tauri.windows.conf.json`, `tauri.macos.conf.json`, `tauri.android.conf.json` and `tauri.ios.conf.json`
2620+
/// (or `Tauri.linux.toml`, `Tauri.windows.toml`, `Tauri.macos.toml`, `Tauri.android.toml` and `Tauri.ios.toml` if the `Tauri.toml` format is used),
26212621
/// which gets merged with the main configuration object.
26222622
///
26232623
/// ## Configuration Structure

core/tauri-utils/src/config/parse.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ impl ConfigFormat {
5454
"tauri.macos.conf.json"
5555
} else if cfg!(windows) {
5656
"tauri.windows.conf.json"
57+
} else if cfg!(target_os = "android") {
58+
"tauri.android.conf.json"
59+
} else if cfg!(target_os = "ios") {
60+
"tauri.ios.conf.json"
5761
} else {
5862
"tauri.linux.conf.json"
5963
}
@@ -63,6 +67,10 @@ impl ConfigFormat {
6367
"tauri.macos.conf.json5"
6468
} else if cfg!(windows) {
6569
"tauri.windows.conf.json5"
70+
} else if cfg!(target_os = "android") {
71+
"tauri.android.conf.json"
72+
} else if cfg!(target_os = "ios") {
73+
"tauri.ios.conf.json"
6674
} else {
6775
"tauri.linux.conf.json5"
6876
}
@@ -72,6 +80,10 @@ impl ConfigFormat {
7280
"Tauri.macos.toml"
7381
} else if cfg!(windows) {
7482
"Tauri.windows.toml"
83+
} else if cfg!(target_os = "android") {
84+
"tauri.android.toml"
85+
} else if cfg!(target_os = "ios") {
86+
"tauri.ios.toml"
7587
} else {
7688
"Tauri.linux.toml"
7789
}
@@ -143,11 +155,13 @@ pub enum ConfigError {
143155

144156
/// Reads the configuration from the given root directory.
145157
///
146-
/// It first looks for a `tauri.conf.json[5]` file on the given directory. The file must exist.
158+
/// It first looks for a `tauri.conf.json[5]` or `Tauri.toml` file on the given directory. The file must exist.
147159
/// Then it looks for a platform-specific configuration file:
148-
/// - `tauri.macos.conf.json[5]` on macOS
149-
/// - `tauri.linux.conf.json[5]` on Linux
150-
/// - `tauri.windows.conf.json[5]` on Windows
160+
/// - `tauri.macos.conf.json[5]` or `Tauri.macos.toml` on macOS
161+
/// - `tauri.linux.conf.json[5]` or `Tauri.linux.toml` on Linux
162+
/// - `tauri.windows.conf.json[5]` or `Tauri.windows.toml` on Windows
163+
/// - `tauri.android.conf.json[5]` or `Tauri.android.toml` on Android
164+
/// - `tauri.ios.conf.json[5]` or `Tauri.ios.toml` on iOS
151165
/// Merging the configurations using [JSON Merge Patch (RFC 7396)].
152166
///
153167
/// [JSON Merge Patch (RFC 7396)]: https://datatracker.ietf.org/doc/html/rfc7396.

tooling/cli/schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "http://json-schema.org/draft-07/schema#",
33
"title": "Config",
4-
"description": "The Tauri configuration object. It is read from a file where you can define your frontend assets, configure the bundler, enable the app updater, define a system tray, enable APIs via the allowlist and more.\n\nThe configuration file is generated by the [`tauri init`](https://tauri.app/v1/api/cli#init) command that lives in your Tauri application source directory (src-tauri).\n\nOnce generated, you may modify it at will to customize your Tauri application.\n\n## File Formats\n\nBy default, the configuration is defined as a JSON file named `tauri.conf.json`.\n\nTauri also supports JSON5 and TOML files via the `config-json5` and `config-toml` Cargo features, respectively. The JSON5 file name must be either `tauri.conf.json` or `tauri.conf.json5`. The TOML file name is `Tauri.toml`.\n\n## Platform-Specific Configuration\n\nIn addition to the default configuration file, Tauri can read a platform-specific configuration from `tauri.linux.conf.json`, `tauri.windows.conf.json`, and `tauri.macos.conf.json` (or `Tauri.linux.toml`, `Tauri.windows.toml` and `Tauri.macos.toml` if the `Tauri.toml` format is used), which gets merged with the main configuration object.\n\n## Configuration Structure\n\nThe configuration is composed of the following objects:\n\n- [`package`](#packageconfig): Package settings - [`tauri`](#tauriconfig): The Tauri config - [`build`](#buildconfig): The build configuration - [`plugins`](#pluginconfig): The plugins config\n\n```json title=\"Example tauri.config.json file\" { \"build\": { \"beforeBuildCommand\": \"\", \"beforeDevCommand\": \"\", \"devPath\": \"../dist\", \"distDir\": \"../dist\" }, \"package\": { \"productName\": \"tauri-app\", \"version\": \"0.1.0\" }, \"tauri\": { \"allowlist\": { \"all\": true }, \"bundle\": {}, \"security\": { \"csp\": null }, \"updater\": { \"active\": false }, \"windows\": [ { \"fullscreen\": false, \"height\": 600, \"resizable\": true, \"title\": \"Tauri App\", \"width\": 800 } ] } } ```",
4+
"description": "The Tauri configuration object. It is read from a file where you can define your frontend assets, configure the bundler, enable the app updater, define a system tray, enable APIs via the allowlist and more.\n\nThe configuration file is generated by the [`tauri init`](https://tauri.app/v1/api/cli#init) command that lives in your Tauri application source directory (src-tauri).\n\nOnce generated, you may modify it at will to customize your Tauri application.\n\n## File Formats\n\nBy default, the configuration is defined as a JSON file named `tauri.conf.json`.\n\nTauri also supports JSON5 and TOML files via the `config-json5` and `config-toml` Cargo features, respectively. The JSON5 file name must be either `tauri.conf.json` or `tauri.conf.json5`. The TOML file name is `Tauri.toml`.\n\n## Platform-Specific Configuration\n\nIn addition to the default configuration file, Tauri can read a platform-specific configuration from `tauri.linux.conf.json`, `tauri.windows.conf.json`, `tauri.macos.conf.json`, `tauri.android.conf.json` and `tauri.ios.conf.json` (or `Tauri.linux.toml`, `Tauri.windows.toml`, `Tauri.macos.toml`, `Tauri.android.toml` and `Tauri.ios.toml` if the `Tauri.toml` format is used), which gets merged with the main configuration object.\n\n## Configuration Structure\n\nThe configuration is composed of the following objects:\n\n- [`package`](#packageconfig): Package settings - [`tauri`](#tauriconfig): The Tauri config - [`build`](#buildconfig): The build configuration - [`plugins`](#pluginconfig): The plugins config\n\n```json title=\"Example tauri.config.json file\" { \"build\": { \"beforeBuildCommand\": \"\", \"beforeDevCommand\": \"\", \"devPath\": \"../dist\", \"distDir\": \"../dist\" }, \"package\": { \"productName\": \"tauri-app\", \"version\": \"0.1.0\" }, \"tauri\": { \"allowlist\": { \"all\": true }, \"bundle\": {}, \"security\": { \"csp\": null }, \"updater\": { \"active\": false }, \"windows\": [ { \"fullscreen\": false, \"height\": 600, \"resizable\": true, \"title\": \"Tauri App\", \"width\": 800 } ] } } ```",
55
"type": "object",
66
"properties": {
77
"$schema": {

0 commit comments

Comments
 (0)