【发布时间】:2022-01-12 05:39:13
【问题描述】:
这是我在使用 Xcode 13 和 iOS 15.1.1 时遇到的一个奇怪错误。我开发了一个简单的应用程序,当我在 iOS 15.1.1 (iPhone 13 Pro) 上运行该应用程序时,在应用程序启动白屏(黑色,以防暗模式打开)之前,会显示几分钟。
有人知道解决这个问题吗?这完全打乱了开发过程并在测试应用程序时中断了流程。构建时间在一分钟之内,您必须等待额外的时间才能让白屏消失。
我尝试了以下解决方案,但没有奏效
- 删除 iOS DeviceSupport 并重新启动 Xcode
rm -r ~/Library/Developer/Xcode/iOS\ DeviceSupport
编辑 1:仅当按下 Xcode 中的运行按钮并从 Xcode 启动后,然后我关闭应用程序并从手机重新启动,它才会正常工作
删除 DerivedData 也不起作用
一些代码供参考:
AppDelegate.swift
import UIKit
import Firebase
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
// MARK: - didFinishLaunchingWithOptions
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
self.window?.rootViewController = storyboard.instantiateInitialViewController()
self.window?.makeKeyAndVisible()
FirebaseApp.configure()
return true
}
// MARK: -
// MARK: UISceneSession Lifecycle
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
// MARK: - didDiscardSceneSessions
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
}
根 VC:
import UIKit
class VC_AppleSignIn: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
print("Hello World!")
}
}
如果需要任何其他代码,请告诉我!
【问题讨论】:
-
分享一些代码。您是否在较低的 iOS 版本上测试过您的项目?
-
我建议您尝试删除 DerivedData 并进行干净的构建。还有一些代码共享会有所帮助
-
如果你不提供更多信息,没有人可以帮助你,你只是丢掉了 50 点的代表。试着理解:没有其他人看到这个问题。因此,如果您希望我们帮助您,您必须帮助我们查看。听起来您可能在启动期间在主线程上做了很多工作,这总是错误的行为。使用 Instruments 找出正在发生的事情。
-
我将编辑问题以添加代码,因为我创建了一个新项目,其中没有任何内容并且它工作得非常好。所以我猜这个错误在我的代码中。我会更新问题
-
这里有一个类似的问题,但他们的解决方案都不起作用:stackoverflow.com/questions/69576384/…