Simulator - Black Screen


I’m at the point in Chapter 5 (View Controllers) where I have just added a second view controller and now have an app that allows the user to select between the two view controllers (temperaturew conversion and map view) using a tab bar controller.

The problem I have having is that the temperature conversion view controller intermittently shows up as a black screen in the simulator. The other view controller (map view) works OK.

I’ve tried various things that have appeared to fix the problem, but then the problem has returned and it turns out that they make no difference after all. These include:

Product / Clean before running the app in the debugger.
Product / Clean, then Product / Build, then run it.
Reboot the computer.
Simulator / Reset Content and Settings…
Various combinations of the above.

The intermittent problem happens on a MacBook Pro that is running El Capitan and XCode 7.3.1.

I decided to upgrade a different Mac to MacOS Sierra and the latest XCode (8.2.1). The difference this made is that I consistently get the black screen on the temperature conversion view controller, and the map view controller still works correctly.

Both Macs are somewhat old so I wonder whether there is a timing issue between XCode and Simulator. But I have no hard evidence for this. Both machines have 8GB RAM and a Core 2 Duo processor. They both run XCode (and other applications) acceptably fast.

Does anyone have any ideas? I found some related threads about this type of problem, but for Cocoa and Objective C rather than Swift targeting iOS.


There’s someone currently posting about the opposite problem: the map view is black.


Thank you, that’s interesting. I’ll keep an eye on that thread.

I might have found my problem (but also see below — I might not have). I installed Xcode 8.2.1 on a newer Mac (MacBook Air with Core i7 processor, which I also upgraded to MacOS Sierra). Initially, this made no difference. Then I opened the Issue Navigator (triangle with exclamation mark in the left pane of Xcode) and found that my project had issues — see screenshot below). I allowed Xcode to fix the problem and the Simulator now correctly displays the temperature conversion view.

On the other hand, when I went back to make the screen shot for this post I got it working without letting Xcode fix that issue. So it’s probably unrelated.


Then I went back to the Mac on which I was having the problem (older Mac running the same version of Sierra and the same version of Xcode) and found that when I opened the same project there, it had different issues (see screen shots below).

I need to do some more investigating but won’t be able to do so until this evening. In the meantime, if anyone has any ideas please let me know.

Interestingly, I can no longer recreate the problem on the third Mac (the one on which I originally saw this problem intermittently). This machine is running El Capitan and Xcode 7.3.1. All three machines have the same version of the project (apart from the automatic upgrades that Xcode 8.2.1 did, and one small code change to the temperature conversion logic that I needed to make to make Xcode 8.2.1 happy.

More to follow. This evening, I hope.


The warnings you posted can all be solved by Update Frames.


Getting back to this later than I expected after the holidays…

Update Frames fixed the layout problems on that particular Mac (as posted above). And it also fixed the black screen problem on that machine. So, thanks for mentioning that!

Then I returned to the Mac on which I originally encountered the black screen problem (the one that is still on El Capitan and Xcode 7.3.1. Whereas I could not get it to do anything other than display the black screen on the simulator before the holidays, now it works perfectly. As far as I’m aware, all I did was not touch my code for about a week.

So I’ll press on with the exercises and not worry about black screens unless it happens again.


Unfortunately, it did not last. Everything worked perfectly until I got to the point in the chapter where I deleted the map view from its view controller. After doing that, and adding the few lines of code to create the map view programmatically, the Simulator window is black again.

I made a backup of my project before deleting the map view, when it was working perfectly. When I reverted to the backup version I again (with no code changes) got the black simulator. I tried deleting content and settings in the simulator, and the other stuff I mentioned further up this thread, but to no avail. So now I have a project that, with no code changes whatsoever, has gone from working correctly with the simulator to getting the black screen.

Unless I’m missing something, Xcode is a very frustrating environment.


Sometimes when weird things happen in the Simulator, I can Quit the Simulator, then rerun my program, which will relaunch the Simulator, and that fixes things. I tend to think that if the Simulator is left running too long, it can malfunction. Or maybe problems occur when I run more than one project at the same time.

Recently, I got a black screen in the Simulator when I knew the view was hooked up correctly, and I quit the Simulator and reran my program, and that fixed the issue.


Thanks, 7. I’ve been trying stuff like that too. I just tried quitting Simulator before my debug session. It made no difference. Then I tried quitting Xcode and Simulator. Again no change. Then I tried resetting contents and settings in Simulator before restarting both. Still no luck. Then I rebooted the Mac and it worked. I could almost live with that if it consistently solved the problem but even a reboot frequently does not solve anything.

I can’t imagine achieving an efficient development workflow in this environment if it keeps screwing up like this.

That was all on a Mac that has the latest OS and Xcode versions installed (Sierra with Xcode 8.2.1).


And I should have added that before all that I blew away all my constraints and recreated them from scratch. Throughout the entire process of trying different workarounds, Xcode told me there were no buildtime issues and no runtime issues.

And this is on my fastest Mac (MacBook Air with Core i7, 8GB RAM and an SSD for storage).


Frustrating. Maybe go through the following thread and try all the suggestions there:

You also may want to try installing another version of Xcode and see if the problem persists. The method I use to have multiple versions of Xcode available is to create a folder in my Applications folder named after the Xcode version, e.g. Xcode8.1. Then I drag out of the Applications folder and into the Xcode8.1 folder, and then I install another version of Xcode, which will create in my Applications folder. You can do that as many times as you want for various Xcode versions. To switch to a version of Xcode you already have installed, just drag in the Applications folder into its version folder, then drag out of one of the other folders and into Applications. You’ll know which version you are currently using by checking which version folder is empty.

For example, I have something like this inside my /Applications folder:





I know the outside of the version folders is for Xcode 7.2 because the Xcode7.2 folder is empty. If I want to switch to Xcode 8.1, I drag the that is outside of any version folder into the Xcode7.2 folder, and then I drag out of the Xcode8.1 folder and into the Applications folder.


Thanks again, I think I tried some things from that StackOverflow thread but thanks for reminding me about it.

Thanks also for the Xcode version idea. I’ll keep that one up my sleeve and give it a try next time.

I’ve carefully gone through the StackOverflow thread you linked to and made a list of things from that thread, things from here, things from elsewhere on the web, and things I’ve tried that appeared on at least one occasion to have had some effect. Here’s a merged list of all those things:

Simulator-related stuff:

  • In Simulator, Reset Content and Settings…
  • Exit Simulator before starting your debug session.
  • While running your app, Command / 3 to scale the Simulator window. This is the same as Window / Scale / 50%. You could try other percentages too.
  • Press Command - l (letter L) to lock the screen, then Command - Shift - H to unlock it (also try Command - Shift - H twice in quick succession).

Xcode-related stuff:

  • In Xcode, Product / Clean.
  • File / Project Settings. Make a note of where Derived Data resides, and delete it.
  • File / Project Settings. Configure your project to display all issues (not just the ones for the active scheme.
  • In Project Navigator, click on the name of your project and make sure that you are targeting the latest version of iOS.
  • Exit Xcode.
  • Apply any available Xcode updates.

Project-related stuff:

  • Make sure that the Issue Navigator is not warning you of any build-time or runtime issues.
  • If there are any constraint-related issues, merely updating frames might help. Otherwise, consider clearing your constraints and creating them afresh.
  • Make sure that if you have any launch images, none of them are missing.
  • Select your launch screen’s storyboard in Project Navigator (over on the left) and make sure that (under File Inspector, on the right) its Use as Launch Screen box is checked.

General stuff:

  • Consider rebooting the computer.
  • Consider updating to the latest version of the operating system.

There is a suggestion in the StackOverflow item that, before resetting the Simulator, one should first go to the project’s “project navigator” screen and under the general -> deployment info screen check that the “main” interface property is properly setup. But I cannot find that in this version of Xcode (8.2.1).


Which one of things mentioned does “that” refer to?


I meant that I could not find anywhere to set the “main” interface, whether under General / Deployment or elsewhere. I found the other deployment-related things but that one eluded me.


Okay. In Xcode 7.2.1, under the General tab and in the section titled Deployment Info I see this:

Deployment Target | 9.2
Devices | Universal
Main Interface | Main
Device Orientation  => Portrait, Landscape Left, Landscape Right are checked, Upside Down unchecked
Status Bar Style | Default

|    select/drop down list
=>   checkboxes

The other choices for Main Interface are LaunchScreen.storyboard and Main.storyboard.

Just so you know, I generally have no problems with the Simulator. If you can’t get your Simulator to work, then the current versions of Xcode and iOS are not ready for prime time, and I would abandon iOS programming altogether until Apple gets their act together. At this point, I think your best hope is to install another version of Xcode that is compatible with your version of OSX. I’m using Xcode 7.2.1 and OSX 10.10.5 on my macbook.

I know I’ve had trouble locating the downloads page for Xcode in the past, so I’ve saved the link:


Thank you once again, 7stud. Something very interesting just happened. When I said I couldn’t find that “main” setting, I was referring to Xcode 8.2.1 (Apple seems to have moved it in Xcode 8). But that doesn’t matter – your post about Xcode 7.2.1 was still very useful.

I decided to go back to my El Capitan / Xcode 7.3.1 machine that suffers the worst from this black Simulator screen problem. I started going through my checklist above. Before completing all the items, I decided to compare my deployment settings to the values that you listed in your most recent post and I found one difference. You have Devices | Universal, but I had Devices | iPhone. When I changed that setting to Universal the black screen problem went away and now my app is correctly displayed in Simulator.

I had not previously changed these settings. Devices | iPhone is what I got by default. I don’t yet want to say that this fixed the problem (once bitten, twice shy). But I will post to this thread later whether it continues to work correctly or not.


Hallelujah! What luck. Those settings were actually from a different app I am currently working on. I just went back and checked my WorldTrotter app, and I have Devices set to iPhone as instructed on p.44 in Chapter 3. The app I’m currently working on is from another book on iOS9 programming: “iOS 9 SDK Development: Creating iPhone and iPad Apps with Swift”. In that book, the authors say that Apple is pushing hard for developers to choose Universal, so that an app can be displayed on any device. By the way, the Devices setting is presented to you when you create a new project–on the same page where you enter the project name I see this:

Language | Swift
Devices |  Universal (other choices: iPhone, iPad)

I’m wondering about something…in Xcode to the right of the Run button is your selected Simulator actually an iPhone Simulator, rather than, say, an iPad Pro Simulator. I’m thinking that if your Devices setting is iPhone and the selected Simulator in Xcode is iPad Pro, then maybe you get a blank screen? That actually is not a problem in Xcode 7.2.1: despite having Devices set to iPhone, I can still run my app in an iPad Simulator (which doesn’t make any sense to me now that I think about it)–however, maybe that changed.

If the Simulator continues to work for you after that change, I think you should consider posting your solution in that stackoverflow thread.


Yes, the iPhone / iPad / Universal option is still there when you create a project in Xcode 8, except that it now defaults to Universal. But iPhone remains an option. I don’t know where you would change that after the fact in Xcode 8. In Xcode 7 you would of course click on the highest level item on the Project Navigator pane and then change the setting on the page that appears on the right, but that page has changed in Xcode 8. I’ve not yet found the iPhone vs iPad vs Universal setting anywhere. I’ll post if I find it. It must surely be there somewhere as that option is presented at project creation time.

My Simulator target is an iPhone. A 6s on my Xcode 7.3.1 machine and a 7 Plus on my 8.2.1 machine.

I will certainly post this to StackOverflow if it stays fixed for a few hours (anything over a couple of hours would be a record).

Thank you again for sticking with this, 7stud. Without your tenacity and help I’m sure I would never have found that setting (always assuming that we have causation here, and not mere correlation).


How about:

In the Project Navigator, select the line with the blue Xcode icon at the top. Then in the Build Settings tab, enter “Device Family” in the search box, which should reveal a setting for “Targeted Device Family” in the Deployment section.

I see 3 options: 1, 2 and 1,2. What do they mean?

iPhone/iPod touch is 1, iPad is 2, and universal (iPhone and iPad) is 1,2.


Yes, that setting is there in Xcode 8. Targeted Device Family is under Deployment Settings (not under Build Options… and there is no ‘Build Settings’)

So that’s what 1 / 2 / 1,2 means!