From 18dffc9dfecaf0c900e233e041d9ca36c92834b5 Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Tue, 10 Dec 2024 14:21:11 -0300 Subject: [PATCH] fix(opener): iOS build (#2189) * fix(opener): iOS build * fix covector --- .changes/fix-opener-ios-fn-name.md | 6 ++++ plugins/opener/ios/Sources/OpenerPlugin.swift | 30 +++++++++---------- 2 files changed, 20 insertions(+), 16 deletions(-) create mode 100644 .changes/fix-opener-ios-fn-name.md diff --git a/.changes/fix-opener-ios-fn-name.md b/.changes/fix-opener-ios-fn-name.md new file mode 100644 index 00000000..f584662c --- /dev/null +++ b/.changes/fix-opener-ios-fn-name.md @@ -0,0 +1,6 @@ +--- +"opener": patch +"opener-js": patch +--- + +Fix usage on iOS. diff --git a/plugins/opener/ios/Sources/OpenerPlugin.swift b/plugins/opener/ios/Sources/OpenerPlugin.swift index 39bc5725..81ff76b4 100644 --- a/plugins/opener/ios/Sources/OpenerPlugin.swift +++ b/plugins/opener/ios/Sources/OpenerPlugin.swift @@ -3,32 +3,30 @@ // SPDX-License-Identifier: MIT import Foundation - import SwiftRs import Tauri import UIKit import WebKit class OpenerPlugin: Plugin { - - @objc public func open(_ invoke: Invoke) throws { - do { - let urlString = try invoke.parseArgs(String.self) - if let url = URL(string: urlString) { - if #available(iOS 10, *) { - UIApplication.shared.open(url, options: [:]) - } else { - UIApplication.shared.openURL(url) - } - } - invoke.resolve() - } catch { - invoke.reject(error.localizedDescription) + @objc public func open(_ invoke: Invoke) throws { + do { + let urlString = try invoke.parseArgs(String.self) + if let url = URL(string: urlString) { + if #available(iOS 10, *) { + UIApplication.shared.open(url, options: [:]) + } else { + UIApplication.shared.openURL(url) } + } + invoke.resolve() + } catch { + invoke.reject(error.localizedDescription) } + } } -@_cdecl("init_plugin_shell") +@_cdecl("init_plugin_opener") func initPlugin() -> Plugin { return OpenerPlugin() }