1

I am a beginner to iOS development. I've run into a weird issue whereby I get this error sometimes when trying to run the application:

Application windows are expected to have a root view controller at the end of application launch

I have a text input, label, and 2 buttons.

The weird thing is, I can fix this error by simply moving an element on the storyboard. However, by moving something again, I often break it and this error appears.

I have checked:

  • my main storyboard file base name is correct in my plist file
  • the main.m UIApplicationMain line never changes
  • my storyboard is set to be the initial storyboard.

I don't understand why moving elements on the storyboard would cause / fix this error.

This is in XCode 5.

EDIT: As requested, 2 screenshots. Working: "Do it" button is seen top most. Build, runs fine. enter image description here

Then, I move "Do it" button below "test". Build, and fails. enter image description here

EDIT2: I did a diff between the broken project and a copy of the working project. This is what I got:

pauls-mbp:Objective C paul$ diff -r CEM1 CEM1.broke
diff -r CEM1/CEM1/Base.lproj/Main.storyboard 
CEM1.broke/CEM1/Base.lproj/Main.storyboard
33c33
<  <rect key="frame" x="156" y="164" width="33" height="30"/>
---
>  <rect key="frame" x="151" y="198" width="33" height="30"/>
43c43
<  <rect key="frame" x="150" y="257" width="44" height="24"/>
---
>  <rect key="frame" x="145" y="236" width="44" height="24"/>
Binary files
CEM1/CEM1.xcodeproj/project.xcworkspace/xcuserdata/paul.xcuserdatad/
UserInterfaceState.xcuserstate and 
CEM1.broke/CEM1.xcodeproj/project.xcworkspace/xcuserdata/paul.xcuserdatad/      
UserInterfaceState.xcuserstate differ
psx
  • 4,040
  • 6
  • 30
  • 59
  • Could you include screenshots of when it works and when it doesn't? Please include the left side bar where it shows the nesting of the different views. – Douglas Nov 18 '13 at 21:18
  • @Douglas Added. I simply moved the "Do it" button a few pixels lower, and boom, error. – psx Nov 18 '13 at 21:24
  • What does your AppDelegate.m look like. Is this a brand new project? What else have you changed besides the VC within the storyboard. – Peter Foti Nov 18 '13 at 21:37
  • @PeterFoti AppDelegate.m is the default. Nothing changed besides moving that element. – psx Nov 18 '13 at 21:43
  • It sounds like a one off bug, I would delete the project and start anew. I doubt you'll be able to recreate the issue. – Peter Foti Nov 18 '13 at 21:44
  • @PeterFoti added a diff between a broken project and a working one. Do you see anything there? – psx Nov 18 '13 at 21:51
  • @psynnott Nothing there would throw an error. – Peter Foti Nov 18 '13 at 21:53
  • Hmm, this makes me lose confidence in continuing with learning Objective-C and iOS Development. I come from a PHP background that generally always has an explanation if something falls over with a fatal error. I've never had an issue in PHP that required me to delete everything and start over. Granted, this is a tiny test app in XCode and wouldn't take that long to recreate, but what if I got this in a project that I'm doing for my company? It worries me. – psx Nov 18 '13 at 21:57
  • 1
    Hm, perhaps the reason it starts working is due to the rebuild, rather than a change to the file. For example, if you get it to break, then just build again (or make a small change to another code file), does it start working again? That error in your console points to some sort of issue with the SDK files, there's some discussion here: http://stackoverflow.com/questions/18036381/xcode-5-error-certuiframework-axbundle?rq=1 – Douglas Nov 19 '13 at 09:39
  • @Douglas This does sound like a very probable solution. I will try this evening when I have access to the machine with the project again – psx Nov 19 '13 at 10:28

1 Answers1

0

Do yo have object with class UIViewController in your storyboard? If no, warning says that you should set root view controller to your app and you should do that.

The other thing is that storybord has still bugs and disappearing warnings caused with moving elements in storyboard could be one of them. Maybe quit and reopen Xcode should help with this issue.

But first verify if you have UIViewController in your storyboard - it is good practice to use it.

lwalukie
  • 89
  • 1
  • 10
  • How would I check if I have an object with class UIViewController in the storyboard? Complete beginner to iOS dev here... – psx Nov 18 '13 at 21:41
  • Update: Yes, the view controller has class ViewController which is inherited from UIViewController. – psx Nov 18 '13 at 22:15
  • Sorry, you don't understand me. What I mean was that in nib it was possible to add view without view controller and I thought that maybe you added view without view controller to your storyboard but it is not possible in storyboard as I checked. – lwalukie Nov 19 '13 at 17:34