Skip to content

Commit d323856

Browse files
committed
fix: fileAssociations missing LSHandlerRank on macOS (#13159)
1 parent 1734273 commit d323856

File tree

9 files changed

+218
-4
lines changed

9 files changed

+218
-4
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"tauri-bundler": patch
3+
"tauri-utils": patch
4+
"tauri-cli": patch
5+
"@tauri-apps/cli": patch
6+
---
7+
8+
Fix `fileAssociations` missing `LSHandlerRank` on macOS.

crates/tauri-bundler/src/bundle/macos/app.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,10 @@ fn create_info_plist(
271271
"CFBundleTypeRole".into(),
272272
association.role.to_string().into(),
273273
);
274+
dict.insert(
275+
"LSHandlerRank".into(),
276+
association.rank.to_string().into()
277+
);
274278
plist::Value::Dictionary(dict)
275279
})
276280
.collect(),

crates/tauri-cli/config.schema.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2345,6 +2345,15 @@
23452345
"string",
23462346
"null"
23472347
]
2348+
},
2349+
"rank": {
2350+
"description": "The ranking of this app among apps that declare themselves as editors or viewers of the given file type. Maps to `LSHandlerRank` on macOS.",
2351+
"default": "Default",
2352+
"allOf": [
2353+
{
2354+
"$ref": "#/definitions/HandlerRank"
2355+
}
2356+
]
23482357
}
23492358
},
23502359
"additionalProperties": false
@@ -2393,6 +2402,39 @@
23932402
}
23942403
]
23952404
},
2405+
"HandlerRank": {
2406+
"description": "Corresponds to LSHandlerRank",
2407+
"oneOf": [
2408+
{
2409+
"description": "LSHandlerRank.Default. This app is an opener of files of this type; this value is also used if no rank is specified.",
2410+
"type": "string",
2411+
"enum": [
2412+
"Default"
2413+
]
2414+
},
2415+
{
2416+
"description": "LSHandlerRank.Owner. This app is the primary creator of files of this type.",
2417+
"type": "string",
2418+
"enum": [
2419+
"Owner"
2420+
]
2421+
},
2422+
{
2423+
"description": "LSHandlerRank.Alternate. This app is a secondary viewer of files of this type.",
2424+
"type": "string",
2425+
"enum": [
2426+
"Alternate"
2427+
]
2428+
},
2429+
{
2430+
"description": "LSHandlerRank.None. This app is never selected to open files of this type, but it accepts drops of files of this type.",
2431+
"type": "string",
2432+
"enum": [
2433+
"None"
2434+
]
2435+
}
2436+
]
2437+
},
23962438
"WindowsConfig": {
23972439
"description": "Windows bundler configuration.\n\n See more: <https://v2.tauri.app/reference/config/#windowsconfig>",
23982440
"type": "object",

crates/tauri-cli/schema.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1966,6 +1966,15 @@
19661966
"string",
19671967
"null"
19681968
]
1969+
},
1970+
"rank": {
1971+
"description": "The ranking of this app among apps that declare themselves as editors or viewers of the given file type. Maps to `LSHandlerRank` on macOS.",
1972+
"default": "Default",
1973+
"allOf": [
1974+
{
1975+
"$ref": "#/definitions/HandlerRank"
1976+
}
1977+
]
19691978
}
19701979
},
19711980
"additionalProperties": false
@@ -2014,6 +2023,39 @@
20142023
}
20152024
]
20162025
},
2026+
"HandlerRank": {
2027+
"description": "Corresponds to LSHandlerRank",
2028+
"oneOf": [
2029+
{
2030+
"description": "LSHandlerRank.Default. This app is an opener of files of this type; this value is also used if no rank is specified.",
2031+
"type": "string",
2032+
"enum": [
2033+
"Default"
2034+
]
2035+
},
2036+
{
2037+
"description": "LSHandlerRank.Owner. This app is the primary creator of files of this type.",
2038+
"type": "string",
2039+
"enum": [
2040+
"Owner"
2041+
]
2042+
},
2043+
{
2044+
"description": "LSHandlerRank.Alternate. This app is a secondary viewer of files of this type.",
2045+
"type": "string",
2046+
"enum": [
2047+
"Alternate"
2048+
]
2049+
},
2050+
{
2051+
"description": "LSHandlerRank.None. This app is never selected to open files of this type, but it accepts drops of files of this type.",
2052+
"type": "string",
2053+
"enum": [
2054+
"None"
2055+
]
2056+
}
2057+
]
2058+
},
20172059
"WindowsConfig": {
20182060
"description": "Windows bundler configuration.\n\n See more: <https://tauri.app/v1/api/config#windowsconfig>",
20192061
"type": "object",

crates/tauri-cli/tauri.config.schema.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1966,6 +1966,15 @@
19661966
"string",
19671967
"null"
19681968
]
1969+
},
1970+
"rank": {
1971+
"description": "The ranking of this app among apps that declare themselves as editors or viewers of the given file type. Maps to `LSHandlerRank` on macOS.",
1972+
"default": "Default",
1973+
"allOf": [
1974+
{
1975+
"$ref": "#/definitions/HandlerRank"
1976+
}
1977+
]
19691978
}
19701979
},
19711980
"additionalProperties": false
@@ -2014,6 +2023,39 @@
20142023
}
20152024
]
20162025
},
2026+
"HandlerRank": {
2027+
"description": "Corresponds to LSHandlerRank",
2028+
"oneOf": [
2029+
{
2030+
"description": "LSHandlerRank.Default. This app is an opener of files of this type; this value is also used if no rank is specified.",
2031+
"type": "string",
2032+
"enum": [
2033+
"Default"
2034+
]
2035+
},
2036+
{
2037+
"description": "LSHandlerRank.Owner. This app is the primary creator of files of this type.",
2038+
"type": "string",
2039+
"enum": [
2040+
"Owner"
2041+
]
2042+
},
2043+
{
2044+
"description": "LSHandlerRank.Alternate. This app is a secondary viewer of files of this type.",
2045+
"type": "string",
2046+
"enum": [
2047+
"Alternate"
2048+
]
2049+
},
2050+
{
2051+
"description": "LSHandlerRank.None. This app is never selected to open files of this type, but it accepts drops of files of this type.",
2052+
"type": "string",
2053+
"enum": [
2054+
"None"
2055+
]
2056+
}
2057+
]
2058+
},
20172059
"WindowsConfig": {
20182060
"description": "Windows bundler configuration.\n\n See more: <https://tauri.app/v1/api/config#windowsconfig>",
20192061
"type": "object",

crates/tauri-schema-generator/schemas/config.schema.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2345,6 +2345,15 @@
23452345
"string",
23462346
"null"
23472347
]
2348+
},
2349+
"rank": {
2350+
"description": "The ranking of this app among apps that declare themselves as editors or viewers of the given file type. Maps to `LSHandlerRank` on macOS.",
2351+
"default": "Default",
2352+
"allOf": [
2353+
{
2354+
"$ref": "#/definitions/HandlerRank"
2355+
}
2356+
]
23482357
}
23492358
},
23502359
"additionalProperties": false
@@ -2393,6 +2402,39 @@
23932402
}
23942403
]
23952404
},
2405+
"HandlerRank": {
2406+
"description": "Corresponds to LSHandlerRank",
2407+
"oneOf": [
2408+
{
2409+
"description": "LSHandlerRank.Default. This app is an opener of files of this type; this value is also used if no rank is specified.",
2410+
"type": "string",
2411+
"enum": [
2412+
"Default"
2413+
]
2414+
},
2415+
{
2416+
"description": "LSHandlerRank.Owner. This app is the primary creator of files of this type.",
2417+
"type": "string",
2418+
"enum": [
2419+
"Owner"
2420+
]
2421+
},
2422+
{
2423+
"description": "LSHandlerRank.Alternate. This app is a secondary viewer of files of this type.",
2424+
"type": "string",
2425+
"enum": [
2426+
"Alternate"
2427+
]
2428+
},
2429+
{
2430+
"description": "LSHandlerRank.None. This app is never selected to open files of this type, but it accepts drops of files of this type.",
2431+
"type": "string",
2432+
"enum": [
2433+
"None"
2434+
]
2435+
}
2436+
]
2437+
},
23962438
"WindowsConfig": {
23972439
"description": "Windows bundler configuration.\n\n See more: <https://v2.tauri.app/reference/config/#windowsconfig>",
23982440
"type": "object",

crates/tauri-utils/src/config.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,34 @@ impl Display for BundleTypeRole {
10901090
}
10911091
}
10921092

1093+
// Issue #13159 - Missing the LSHandlerRank and Apple warns after uploading to App Store Connect.
1094+
// https://github.com/tauri-apps/tauri/issues/13159
1095+
/// Corresponds to LSHandlerRank
1096+
#[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize, Serialize)]
1097+
#[cfg_attr(feature = "schema", derive(JsonSchema))]
1098+
pub enum HandlerRank {
1099+
/// LSHandlerRank.Default. This app is an opener of files of this type; this value is also used if no rank is specified.
1100+
#[default]
1101+
Default,
1102+
/// LSHandlerRank.Owner. This app is the primary creator of files of this type.
1103+
Owner,
1104+
/// LSHandlerRank.Alternate. This app is a secondary viewer of files of this type.
1105+
Alternate,
1106+
/// LSHandlerRank.None. This app is never selected to open files of this type, but it accepts drops of files of this type.
1107+
None,
1108+
}
1109+
1110+
impl Display for HandlerRank {
1111+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1112+
match self {
1113+
Self::Default => write!(f, "Default"),
1114+
Self::Owner => write!(f, "Owner"),
1115+
Self::Alternate => write!(f, "Alternate"),
1116+
Self::None => write!(f, "None"),
1117+
}
1118+
}
1119+
}
1120+
10931121
/// An extension for a [`FileAssociation`].
10941122
///
10951123
/// A leading `.` is automatically stripped.
@@ -1131,6 +1159,9 @@ pub struct FileAssociation {
11311159
/// The mime-type e.g. 'image/png' or 'text/plain'. Linux-only.
11321160
#[serde(alias = "mime-type")]
11331161
pub mime_type: Option<String>,
1162+
/// The ranking of this app among apps that declare themselves as editors or viewers of the given file type. Maps to `LSHandlerRank` on macOS.
1163+
#[serde(default)]
1164+
pub rank: HandlerRank,
11341165
}
11351166

11361167
/// Deep link protocol configuration.

examples/file-associations/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
]
88
},
99
"scripts": {
10-
"tauri": "node ../../packages/cli/node/tauri.js"
10+
"tauri": "node ../../packages/cli/tauri.js"
1111
},
1212
"devDependencies": {}
1313
}

examples/file-associations/src-tauri/tauri.conf.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,18 @@
2222
"fileAssociations": [
2323
{
2424
"ext": ["png"],
25-
"mimeType": "image/png"
25+
"mimeType": "image/png",
26+
"rank": "Default"
2627
},
2728
{
2829
"ext": ["jpg", "jpeg"],
29-
"mimeType": "image/jpeg"
30+
"mimeType": "image/jpeg",
31+
"rank": "Alternate"
3032
},
3133
{
3234
"ext": ["gif"],
33-
"mimeType": "image/gif"
35+
"mimeType": "image/gif",
36+
"rank": "Owner"
3437
}
3538
]
3639
}

0 commit comments

Comments
 (0)