How to Fix the Most Common Xcode Errors

This article is a collection of the most common issues that I see the students of my course and audience members getting stuck on as well as how to fix them.

I thought writing up this reference will be handy to point people to in the future and I’ll continue to update it with new questions/issues that crop up from my students so please bookmark it!


ARTICLE CONTENTS

1. Xcode Simulator Errors
SpringBoard failed to launch application with error: 0
My iPhone simulator looks different?
My simulator screen is black when the app runs

2. App Runs And Then Crashes
Finding the error message after a crash
Unrecognized selector sent to instance
This class is not key value coding-compliant for the key…

3. Xcode Errors/App Won’t Run
Xcode complains that a method of some class doesn’t exist
Xcode warnings

4. My Xcode Interface Is Different
Missing panels or views
Can’t find UIElements in my Storyboard
Can’t drag UIElements onto my Storyboard


1. Xcode Simulator Errors


SpringBoard failed to launch application with error: 0

SpringBoard simulator error

If you get the error above when you try to run your application, the fix is really simple.
All you need to do is make sure your Simulator is the active window, and then open up the menu pictured below and click “Reset Content and Settings…”

simulator reset content and settings

It will ask you if you really want to reset and you should say yes.
Note that this will delete all the installed apps and settings on your iPhone simulator and reset it back to the original state.

Now when you run your app from Xcode again, you won’t get that error.


My iPhone simulator looks different?

If your iPhone simulator doesn’t look like the one you see me using in my videos, it’s because your iOS simulator is at a different zoom level.

The frame or bezel on the simulator also differs from level to level so if you don’t see an iPhone bezel on your simulator, try changing your zoom level as shown in the screenshot below.

ios simulator zoom level

You can also hit command + 1-3 on your keyboard as shortcut keys to control the zoom level of your simulator.


My simulator screen is black when the app runs

If you run your app and the iOS simulator is showing a black screen, I would first wait a little while. Sometimes it can take up to 15 seconds to launch your app initially.

Secondly, I would reset the simulator like I mentioned above and try to run my app again.

If that still doesn’t work, then maybe you have accidentally set some breakpoints which is stopping the app execution.

Run your app, then bring Xcode to the foreground and see if you see something like the below with a green line (representing where execution has halted) stopped at a blue marker (which is a breakpoint):

xcode breakpoint simulator black screen

If you see something like the above screenshot, that means that you’re seeing a black screen because the app execution has stopped. All you need to do is to either remove the breakpoint by clicking the blue marker and dragging it off the gutter (and then re-run your app).

Or you can disable all breakpoints by this menu command in Xcode:
Xcode deactivate breakpoints

I see this happening a lot for beginners who aren’t aware of what breakpoints are.

Breakpoints are used to halt execution at a certain point so that you can inspect variables and peek into your objects to debug.

You can set breakpoints by clicking the gutter beside a line of code and it’ll add a little blue marker there. So you can see why beginners may accidentally have set breakpoints and not realize it when they run their app!

2. App Runs And Then Crashes


Finding the error message after a crash

When your app runs and then crashes (whether it crashes as soon as your run it or it crashes after you click something), you need to know where to find the error message so that you can see what’s wrong.

After the crash, go to Xcode in the lower right hand pane, scroll all the way to the top.
error message in debug console


Unrecognized selector sent to instance error

unrecognized selector sent to instance

So now that you know how to find the actual error message when your app crashes, the next step is to learn to recognize some of the more common types of messages because they will hint at what’s wrong.

The unrecognized selector error means that somewhere, a method was called on an object and that object didn’t have that method so it crashes. “Selector” is another term for a method.

As you can see in the error message above, it tells you the method that was called was “showDieNumber” and the object that it was called on was a UIView object.

So now you can go back to your code and see where you’re calling the “showDieNumber” method and why the object doesn’t have that method.

Check if that method exists in the header (.h) file of the class and pay attention to the parameters and letter casing to make sure it matches.

If you’re calling a method on a IBOutlet property that is referring to an element in your storyboard, then make sure that the UIElement has it’s custom class set to the class that has the “showDieNumber” method.

setting custom class in storyboard


This class is not key value coding-compliant for the key

If you’re using Storyboards to build your user interface and you encounter a detailed error similar to this:

*** Terminating app due to uncaught exception ‘NSUnknownKeyException’, reason: ‘[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key handleButtonClick.’

The actual name of the key (in this case “handleButtonClick” may be different for you), but this error may indicate that there’s a UIElement in your Storyboard that’s connected to a property which doesn’t exist anymore. This can occur if you connected the UIElement to a property and then removed the property from the .H file.

In order to fix it, go into your storyboard and right click each element to check the connections to the properties and “break” any connections to properties that don’t exist in your .H file anymore by clicking the little “x” beside each bad connection.

3. Xcode Errors/App Won’t Run


Xcode complains that a method of some class doesn’t exist

If you run your app and you get some build errors, that means Xcode has detected that the syntax of your code is wrong.

If Xcode is complaining about a specific identifier doesn’t exist, or the “@end” tag is missing, then check that all of your opening curly braces have corresponding closing curly braces.

If you look at the two screenshots below, both build errors are caused because of missing curly braces. Can you spot the missing curly brace?

missing closing curly brace
missing closing curly brace


Xcode warnings

Xcode warnings are highlighted in yellow and they won’t stop you from running your app but it’s a good practice to reduce the number of them.

I’ll be illustrating some of the more common ones in the future in this section.

4. My Xcode Interface Is Different


Missing panels or views

If you’re missing some panes in your Xcode interface, you can check the buttons in the upper right corner. They’re used to toggle the main panels.

toggle xcode panels and views

In the debug/console area, there are also a couple of buttons to toggle the panes in the debug area:
toggle debug views

If you’re in Storyboard designer view, there’s a button that many people miss. This button controls the document outline which lists the UI Elements in your storyboard in a tree hierarchy view.

toggle storyboard document outline


Can’t find UIElements in my Storyboard

If you don’t see the UI elements list in your storyboard view then your library pane may be on the wrong tab. See the screenshot below:

uielement library tabs


Can’t drag UIElements onto my Storyboard

If you drag UI elements onto your storyboard and you can’t add any to your view, then you may be in zoomed out view. When you’re zoomed out in your storyboard, you can’t add any elements into the view. The zoomed out view gives you and overview of your views and allows you to position your controllers on the storyboard.

To get back into zoomed in view, just double click on an empty area on your storyboard and you’ll zoom back in and be able to drag elements onto your views.

27 thoughts on “How to Fix the Most Common Xcode Errors”

  1. Hi Chris, in the iOS Simulator, in the WAR game tutorial, I started getting a white strip across the bottom. But I don’t see any elements in the storyboard that would have created this and the green background appears to cover everything. The sizing of the simulator suggests that the white part would be out of the frame of the phone (although I’m not 100% sure). Is this some view option I’ve accidentally selected? It doesn’t appear to be “coded,” as best I can tell. Is there a way to get this to go away.

  2. Hi Chris, I am a newby to coding and I am having an issue with Xcode 6 orientation. In the simulator the app is slightly off centre and is situated in the upper left corner. If I run the app on my ipad (Now iOS8.1.1) the image is rotated sideways. Everything was fine until I updated to iOS8 and Xcode 6! Any help would be appreciated as I have had no luck anywhere else. Regards James

  3. Hi Chris, I am reskinning an app and it works fine with all the simulators but with the iPad versions… the falling characters are not visible… you can click where they would be but they are not visible… rest of the game play works fine…any suggestions?

  4. Hey Chris, I’m a beginner at swift and I’m trying to build an app that uses arrays to put sentences together. I attached it to a button in X-Code, but when i open the app in the sim, it only runs once and the button no longer refreshes the app. I have to restart the app to get a new sentence. Do you know how I can fix this problem?

  5. Hello Chris… I have a problem on my XCode. I transfered my project files on another folder and after I run my project on XCode, this what happened: The UIElements in my storyboard are gone! But when I try to run the project, it runs perfectly. In my ViewController, the names of the UI components are colored Gray, not Black. What does it mean? Here is the screenshot… Do I need to reinstall XCode on my macbook? Thank you very much.

    • Hey Jerald, the elements are in a different size class so all you have to do is click that “wAny hAny” button near the bottom center, and then find the one which is “wCompact hAny” and select it. Sorry, i should’ve mentioned that in my video!

  6. hi chris, i h’d applied all thing you mentioned in 1 point . After removing all breakpoints still the simulator is showing the grey screen… am using xcode 6.1 and getting this issue is this version only . The app was running in previous versions

  7. Hi Chris, first of all, thank you for this great series of videos! Your course has been extremely helpful! For some reason, only the background is showing up in the simulator, but not the playing cards. (I’m on episode 11, right before you show how to make the button change the cards dynamically.) I tried all the troubleshooting tips like zooming out, etc, but nothing seems to work. Any suggestions? (And it’s also not because the background is on top of the cards, I checked that as well)

    • Hey Dixon, do you have autolayout turned on? If so, that might explain it!
      In your storyboard, if you select the view controller like in the screenshot, the autolayout checkbox is in the first tab of the inspector pane.

      • Hi Chris, thanks for your quick reply! I just checked, and I do have autolayout turned on. Just to clarify, when you say “…do you have autolayout turned on? If so, that might explain it!” do you mean that I should turn it off? I attempted to do that and it came up with a warning, so I just wanted to clarify first.

        • Right! Turn it off and it’ll probably ask you to disable size classes to.
          Auto layout is a way to position things by describing rules so what you see in the storyboard won’t translate to what you get when you run the app.
          If you want to start with positioning/sizing as exactly what you see in the storyboard, then turn Autolayout off.

          • Ah, it works now! Thank you so, so much! For some reason, before I turned off autolayout, the background was in the right place (behind the cards), but when I turned it off, it showed the background image in a position where it was indeed covering up the cards! (Seems like this fact was being concealed when I had autolayout on). Thanks again for your advice!

  8. Chris, thank you for this article. Do you know why Xcode 5.1.1 crashes when I attempt to drag a UIElement from the Storyboard to my model? I unchecked the Auto Layout box under Storyboard -> Navigator, but it is still crashing. Thanks!

  9. Chris thank you so much ! I was able to fix my issue, and actually understand why I got the error.
    You’re amazing!

  10. Hi, I am trying to display the postal code of the current location in my map. My project compiles but i get libc++abi.dylib: terminating with uncaught exception of type NSException error at run time

    can you help?

    • Hello Deepti, are you following one my tutorials? Otherwise, I might not be able to help you very efficiently if I don’t know how your project works! Try to find the detailed error like I show in this article and Google the error message. It will give you an idea of what’s wrong and you can then look into your code.

Leave a Comment

Share
Tweet
Pin