4

I need help using Interface builder to create a storyboard and initial view, using xCode 6 and Swift. I do not want to start with the template "Single View Application" but with an "Empty Application" - for learning purposes.

I am starting with File->New->Application in xCode 6. In the left pane I have selected iOS-> Application and I am choosing the template "Empty Application"

So now, I have my empty application and I want to use Interface Builder to create a story board.

I select File-New-File - then in the left pane I select iOS-User Interface and in the right pane I select Storyboard. I call my storyboard "Main"

That seems to do nothing, so then upon examining other templates, I decided that I need to go to info.plist and add a key/value pair, and so in info.plist I added a key "Main storyboard file base name" and a value of "Main"

After that I get the error:

Failed to instantiate the default view controller for UIMainStoryboardFile 'Main' - perhaps the designated entry point is not set?

So now I go to the story board and drag and drop a "View Controller" onto the storyboard, and btw - in the View controller inspector it is checked "initial scene - Is Initial View Controller"

But this doesn't create any swift file - which may be expected, but just to be clear it doesn't. Now when I try to run, I get the error:

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

So any ideas? I am trying to figure out how you properly use Interface Builder to create a storyboard and initial view and do a basic hello world, without skipping past the use of the tool to have it created for me in a template, because my assumption is you will quickly have more complex apps than can be created from a template, and it might be good to know how to use the tools - but I am not finding documentation on the subject.

Edit: strange timing I happened to find the answer just as someone else had also correctly answered the issue for me, so I will edit this post and remove the answer - as the answer below is exactly correct.

7
  • Hey guys, go ahead an let me know what it is you find so offensive. Commented Jun 15, 2014 at 1:38
  • i did not downvote but i guess it's a combination of: no code, too much text, and the premise to start with an empty app is odd and i doubt it helps to learn because what you learn there is painful setup that has already been done for you by Apple while the more important learning would be to actually build an app. This makes any answers likely not helpful to others, which is an important aspect to consider on stackoverflow. Commented Jun 15, 2014 at 7:13
  • Thanks, I see that the community in general is misguided. Commented Jun 16, 2014 at 19:45
  • To others that think like you. Interface Builder is designed to build interfaces without code. In titanium, all interfaces were done only with code, but in the Apple world, IB is a legitimate tool. Going beyond apple's templates is something a curious person would do, they'll be a better coder, not a worse one for learning the details. The main thing the community is clearly doing, is falsely believing Apple iBook documents swift, but it does not. Only the core language. If you didn't come from Objective-C - apple, to date, did not document Cocoa(Touch) in Swift. Commented Jun 16, 2014 at 19:55
  • I do appreciate your answer, but this isn't about me, I could care less, I'm seeing other people's legitimate and helpful questions being routinely down voted on stack overflow, by a hostile group that doesn't understand the influx of non-Objective-C coders to the Swift language - and falsely believes they aren't asking legit questions. Anyone want to point me to where, all the methods of UILable were documented in Swift? You can't. Commented Jun 16, 2014 at 19:58

1 Answer 1

3

The storyboard automatically creates the window and instantiates the initial view controller for you. The code in the app delegate is creating another window which you don't want. You should delete all the code in didFinishLaunchingWithOptions, except for "return true". It will then run properly.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! That's what it turned out to be.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.