URL 打开 Swift 应用程序 - 打开作品 - 调用的函数不起作用

Hir*_*Jim 7 debugging xcode ios swift

大家好 - 我是这里的新手......试图让我的第一个 iOS Swift (Xcode 11.2.1 / Swift 5 / iOS 13.2) 应用程序通过 URL 打开并处理 URL 字符串。应用程序打开得很好,但函数(方法?)似乎没有被调用。这是我所拥有的:

class AppDelegate: UIResponder, UIApplicationDelegate {

    func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
        print("Here I iz ... in the URL responding bit.")
        print(url)
        return true
    }

...
Run Code Online (Sandbox Code Playgroud)

该代码位于我项目的AppDelegate.swift文件中。

我的应用程序的 Info.plist

这就是我在Info.plist文件中的内容。

我在设备上和模拟器中通过 Safari 启动 confirmevent://HelloWorld

正如我所说......应用程序正在打开,但我在 Xcode 调试区域中没有看到我的打印语句的任何结果。

在搜索其他帖子时,他们说我需要使用“等待可执行文件启动”将 Xcode 附加到应用程序,我已经完成并且确实附加了。 但是我注意到,当我通过“等待可执行文件启动”选项打开时,我在应用程序中散布的数十个打印语句没有一个出现。

任何/所有帮助将不胜感激。我花了超过 5 个小时在网上搜索,但所有迹象都表明应该“正常工作”

Mul*_*uli 12

我刚刚在这里找到了一个解决方案:application(...continue userActivity...) method not called in ios 13

诀窍是还SceneDelegate.swift为 iOS > 13 的应用程序实现这些功能。如果您打开 URL,则应调用此功能confirmevent://HelloWorld

func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
    print(URLContexts.debugDescription)
}
Run Code Online (Sandbox Code Playgroud)