Skip to content

Commit 2b9c4d3

Browse files
lucasfernoggezihuzi
authored andcommitted
fix(opener): iOS build (tauri-apps#2189)
* fix(opener): iOS build * fix covector
1 parent 118c557 commit 2b9c4d3

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

.changes/fix-opener-ios-fn-name.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"opener": patch
3+
"opener-js": patch
4+
---
5+
6+
Fix usage on iOS.

plugins/opener/ios/Sources/OpenerPlugin.swift

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,30 @@
33
// SPDX-License-Identifier: MIT
44

55
import Foundation
6-
76
import SwiftRs
87
import Tauri
98
import UIKit
109
import WebKit
1110

1211
class OpenerPlugin: Plugin {
13-
14-
@objc public func open(_ invoke: Invoke) throws {
15-
do {
16-
let urlString = try invoke.parseArgs(String.self)
17-
if let url = URL(string: urlString) {
18-
if #available(iOS 10, *) {
19-
UIApplication.shared.open(url, options: [:])
20-
} else {
21-
UIApplication.shared.openURL(url)
22-
}
23-
}
24-
invoke.resolve()
25-
} catch {
26-
invoke.reject(error.localizedDescription)
12+
@objc public func open(_ invoke: Invoke) throws {
13+
do {
14+
let urlString = try invoke.parseArgs(String.self)
15+
if let url = URL(string: urlString) {
16+
if #available(iOS 10, *) {
17+
UIApplication.shared.open(url, options: [:])
18+
} else {
19+
UIApplication.shared.openURL(url)
2720
}
21+
}
22+
invoke.resolve()
23+
} catch {
24+
invoke.reject(error.localizedDescription)
2825
}
26+
}
2927
}
3028

31-
@_cdecl("init_plugin_shell")
29+
@_cdecl("init_plugin_opener")
3230
func initPlugin() -> Plugin {
3331
return OpenerPlugin()
3432
}

0 commit comments

Comments
 (0)