Run the iOS simulator with Xcode and get a black screen, and then Xcode hangs and cannot stop the tasks

I'm having trouble launching my main iPhone application (while watching Stanford ITunes CS193p lectures) in the iOS simulator.

I searched for a while (both Google and SO), but so far I have not been able to find a solution. There are many similar errors, but the solutions do not seem to fix this.

In Xcode, I click run. It compiles and builds successfully, runs an iOS simulator, but it never loads into the application. Only the status bar is at the top. With a black screen.

I wrote a very simple code (following along with the lectures) and cannot overcome this problem.

To confuse more, I wrote a web cover (UIWebView) before these lectures, and it works great. But in the code there is practically no difference. All new applications that I create from scratch fail with the same black screen issue.

If I pressed the home button on the simulator and launched the application, it will be displayed. But Xcode doesn't seem to know what is going on.

It’s as if Xcode has lost the ability to talk to iOS Simulator and suggests that it works (even if I leave the iOS simulator). I am trying to exit Xcode and it asks me to stop the tasks. Then it just freezes. So I need to force restart to exit Xcode.

I use: OSX 10.8.2 Xcode 4.5.2 iOS Simulator 6.0

CalculatorAppDelegate.h

 #import <UIKit/UIKit.h> @interface CalculatorAppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @end 

CalculatorAppDelegate.m

 #import "CalculatorAppDelegate.h" @implementation CalculatorAppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions (NSDictionary *)launchOptions { // Override point for customization after application launch. return YES; } - (void)applicationWillResignActive:(UIApplication *)application { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. } - (void)applicationDidEnterBackground:(UIApplication *)application { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. } - (void)applicationWillEnterForeground:(UIApplication *)application { // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. } - (void)applicationDidBecomeActive:(UIApplication *)application { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. } - (void)applicationWillTerminate:(UIApplication *)application { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } @end 

CalculatorViewController.h

 #import <UIKit/UIKit.h> @interface CalculatorViewController : UIViewController @property (weak, nonatomic) IBOutlet UILabel *display; @end 

CalculatorViewController.m

 #import "CalculatorViewController.h" @implementation CalculatorViewController @synthesize display = _display; - (IBAction)digitPressed:(UIButton *)sender { NSString *digit = [sender currentTitle]; NSLog(@"digit pressed = %@", digit); } @end 
+73
ios xcode ios-simulator
03 Feb '13 at 1:09
source share
22 answers

Surprisingly, I managed to go to the iOS Simulator menu and click "Reset content and settings." (in iOS 13, this is under Hardware)

+78
Jul 12 '13 at 15:37
source share

Before restarting the emulator, first go to the "Project Navigator" screen on your projects screen, and on the general information screen β†’ depoyment info, check that the properties of the main interface are correctly configured!

enter image description here

+41
Jan 22 '14 at 9:16
source share

I am new to iOS app development. I practiced the development of applications for iOS from the very beginning and when I launched the very simple Hello World application, I also had the same problem that after creating and running the application in the iOS simulator, only a black blank screen appeared. One way or another, trying to find a solution to the problem, I accidentally pressed Window β†’ Scale β†’ 50% in the iOS simulator, and this solved my problem. Then I could see the home page with my application and click the application icon. I was able to successfully launch my application. Application Options: Xcode 5.1 iOS Simulator: 7.1 OSX: 10.9.3

+8
Jul 21 '14 at 9:42 on
source share

This may be due to incorrect configuration of deployment information. (i.e. if the storyboard is not set as the main interface)

+5
Nov 22 '13 at 14:17
source share

Another solution is that if you create a UI programmatically in an Objective-C project, you may need to add code to inflate the view, so you will need to add these 3 lines so that the window interface interacts with the code (external 2 actually interacts with the code, and another changes the screen to white so you know that it works).

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. ... self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; return YES; } 
+5
Aug 19 '15 at 18:32
source share

Solution 1: You can Quit simulator and try again.

Solution 2 (recommended): go to iOS Simulator Reset Content and Settings...

Step 1

A message appears with the message 'Are you sure you want to reset the iOS Simulator content and settings?'

Step 2

Select Reset if you want, or the Don't Reset button.

Please note that after you post the content for the simulator reset, the entire application installed on the simulator will be deleted and it will be reset to the initial settings.

+5
Sep 23 '15 at 6:25
source share

If you are using SwiftUI

If you are upgrading from a previous version of Xcode 11, in SceneDelegate willConnectTo session: options connectionOptions SceneDelegate willConnectTo session: options connectionOptions some changes willConnectTo session: options connectionOptions initialization willConnectTo session: options connectionOptions :

The main window now initialized using UIWindow(windowScene: windowScene) , where it is used as UIWindow(frame: UIScreen.main.bounds)

On the previous version:

  let window = UIWindow(frame: UIScreen.main.bounds) window.rootViewController = UIHostingController(rootView: ContentView()) self.window = window window.makeKeyAndVisible() 

In the new version:

  if let windowScene = scene as? UIWindowScene { let window = UIWindow(windowScene: windowScene) window.rootViewController = UIHostingController(rootView: ContentView()) self.window = window window.makeKeyAndVisible() } 
+5
Jul 14 '19 at 11:06
source share

If you lose your entry point in your storyboard or just want to change the entry point, you can specify it in Interface Builder. To set a new entry point, you must first decide which ViewController will act as the new entry point, and in the attribute inspector, select the "Start Scene" checkbox.

You can try: http://www.scott-sherwood.com/ios-5-specifying-the-entry-point-of-your-storyboard/

+4
Nov 12 '14 at 4:57
source share

Restarting your computer should be all you need.

+3
Feb 12 '13 at 21:09
source share

I managed to find a fix for this. This was acknowledged by the courtesy of this blog post:

http://vandadnp.wordpress.com/2012/03/18/xcode-4-3-1-cannot-attach-to-ios-simulator/

The solution is to press cmd + shift +, (command, shift, and then the comma ",") .., which loads some parameters for release or debugging.

Change the debugger from LLDB to GDB. This fixes the problem.

0
07 Feb '13 at
source share

To make sure this is a simulator problem, see if you can connect to the simulator with a completely new project without changing any code. Try the tab bar template.

If you think this is a simulator problem, click the iOS Simulator menu. Select "Reset Content and Settings ...". Click "Reset."

I don’t see your XIB and what @properties you connected in Interface Builder, but it may also be that you are not loading your window or that your window is not loading your view controller.

0
Feb 07 '13 at
source share

I had the same problem with Xcode ... black screen when starting applications, without debugging and clicking Xcode lock.

I finally found the problem ... after the simulator could not connect to Xcode, I looked at my etc / hosts file and found that a few months ago, to solve another problem, I edited the host file to match localhost for my fixed IP instead of the default value ... my value is:

10.0.1.17 localhost

This should work, as this is my IP address, but changing it to a fixed Xcode default IP address ...

127.0.0.1 localhost

Hope this helps.

0
Dec 23 '13 at 15:54
source share

I did what doug ("Reset Content and Settings") offers, which works, but takes a lot of time, and it is very annoying ... until I found a completely random other solution that is much faster and seems to work as well so far! Just press cmd + L on your simulator or go to the simulator menu "Hardware β†’ Lock", which locks the screen, when you unlock the screen, the application works as if nothing had happened :)

0
Feb 13 '14 at 16:40
source share

What happened to me, the class type was not a UIViewController for the script connected to my view controller. It was for UITabController ..... I mistakenly quickly created the wrong type of the class ... So make sure the class, if the correct type .. I hope this helps someone. I was in a hurry and made this mistake.

0
Mar 30 '16 at 4:27
source share

Just reset your simulator by clicking Simulator-> reset Contents and Settings.

0
Dec 08 '16 at 10:20
source share

you can also go to Hardware β†’ reboot, then Hardware β†’ Home and click on your application

0
08 Oct 2018-01-17T00:
source share

Please make sure you do this if you get a black screen after copying the storyboard from another project. enter image description here

0
Jan 28 '18 at 3:23
source share

Make sure the controller’s initial view is set.

0
Jun 06 '18 at 22:03
source share

I decided this only after removing the simulators with previous versions of iOS.

0
Jun 26 '18 at 8:17
source share

I had black simulator screens only for iOS 11 sims. After trying to reset, reboot, reinstall and create a new user account on my computer, I found the following solution:

 defaults write com.apple.CoreSimulator.IndigoFramebufferServices FramebufferRendererHint 3 

find in this answer here: Xcode 9 iOS Simulator goes black after installing Xcode 10 beta

0
Aug 28 '18 at 20:31
source share

Please check all restrictions for all kinds and view the full storyboard. This usually happens because of this.

Regards, Arora

0
Jan 22 '19 at 7:54
source share

If you recently upgraded to Xcode 11 beta 3 and tried to start an older SwiftUI project, you need to make some changes to SceneDelegate, where the views are loaded, otherwise the screens will remain black on devices running iOS 13 beta 3, which, of course, includes everything 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 is not strictly limited to simulators, but since most people will run beta software exclusively on simulators, this will happen only in this context. This baffled me for quite some time, so hope this helps.

0
Jul 10 '19 at 9:26
source share



All Articles