我们将应用程序从SwiftUI迁移到UIKit生命周期和应用程序容器中,创建了标准的AppDelegate、SceneDelegate,并更新了所需的信息.plist属性.我没有学习本教程,但如果您不熟悉,这也正是我们所做的.https://mokacoding.com/blog/how-to-migrate-from-swiftui-to-uikit-life-cycle/
我们的问题是,安装了具有SwiftUI生命周期的应用程序的物理iPhone设备出现黑屏,并且在发布时没有响应.调试证明,这是因为从未调用过SceneDelegate
个设置函数.iPhone模拟器、building to Mac等工作正常.
删除应用程序并重新安装可以解决此问题,但我们无法从我们的安装群中要求.
Is there any way to force installed apps to clear their cache or whatever it is that controls launch configurations?
这是相关代码.
AppDelegate, this is being called
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
return true
}
SceneDelegate, this is NOT being called
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let scene = scene as? UIWindowScene else { return }
window = UIWindow(windowScene: scene)
let viewController: UIViewController
if isLoggedIn {
viewController = MainViewController()
} else {
viewController = UIHostingController(
rootView: LandingView().injectingEnvironment()
)
}
window!.rootViewController = viewController
window!.makeKeyAndVisible()
}
info.plist
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<true/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
</dict>
</array>
</dict>
</dict>