Launch iOS simulator from Xcode and getting a black screen, followed by Xcode hanging and unable to stop tasks

后端 未结 26 2285
一整个雨季
一整个雨季 2020-11-29 05:16

I\'m having trouble running my basic iPhone application (while going through the Stanford iTunes CS193p lectures) in the iOS simulator.

I\'ve been searching for a wh

相关标签:
26条回答
  • 2020-11-29 05:30

    I had the same issue with Xcode... black screen on launching apps, no debugging and clicking would lock up Xcode.

    I finally found the problem... following the lead that the simulator could not connect to Xcode I took a look at my etc/hosts file and found that months ago to solve a different issue I had edited the host file to map localhost to my fixed IP instead of the default... my value:

    10.0.1.17 localhost

    This should work since that is my IP, but changing it back to the default IP fixed Xcode...

    127.0.0.1 localhost

    Hope this helps.

    0 讨论(0)
  • 2020-11-29 05:30

    What happened with me was the Type of class was not UIViewController for the script attached to my view controller. It was for a UITabController..... I had mistakenly quickly created the wrong type of class.... So make sure the class if the correct type.. Hope this helps someone. I was in a rush and made this mistake.

    0 讨论(0)
  • 2020-11-29 05:30

    In case you recently updated to Xcode 11 beta 3 and try to run an older SwiftUI project, you have to make some changes in the SceneDelegate where the views are loaded, otherwise the screens will remain black on devices running iOS 13 beta 3 which of course includes all simulators.

        func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
        // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
        // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
    
        // Use a UIHostingController as window root view controller
        if let windowScene = scene as? UIWindowScene {
            let window = UIWindow(windowScene: windowScene)
            window.rootViewController = UIHostingController(rootView: ContentView())
            self.window = window
            window.makeKeyAndVisible()
        }
    }
    

    The behavior not strictly limited to the simulators, but since most people will run beta software exclusively on simulators it will only occur in this context. It baffled me for quite a while, so hope it helps.

    0 讨论(0)
  • 2020-11-29 05:30

    I was developing flutter using android studio and running the simulator, the simulator was dark and I reset the contents as per accepted answer. But that didn't fix my issue. My CPU was running somehow high enough, so I restarted , but not fixed the issue. I opened Xcode and run one of my native iOS apps, the simulator re-opened as usual. I closed the Xcode and opened Android Studio, then started developing flutter app again.

    0 讨论(0)
  • 2020-11-29 05:30

    I solved this question with set window background color like this in iOS 13:

    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        guard let _ = (scene as? UIWindowScene) else { return }
        if let windowScene = scene as? UIWindowScene {
            window = UIWindow(windowScene: windowScene)
            window?.backgroundColor = .white
            let storyBoard = UIStoryboard(name: "Main", bundle: nil)
            
            // workaround for svprogresshud
            let appDelegate = UIApplication.shared.delegate as! AppDelegate
            appDelegate.window = window
        }
    }
    
    0 讨论(0)
  • 2020-11-29 05:31

    I solved this only after removing simulators with prior iOS versions.

    0 讨论(0)
提交回复
热议问题