0

I updated my Xcode to 7.3. Before update I was able to run my code with any errors or crashes. After update I get assertion error when I run the below code on iPhone (Interesting no error on simulator).

let storyboard =  UIStoryboard(name: storyboard, bundle: nil)
self.window?.rootViewController = storyboard.instantiateInitialViewController() as UIViewController!

Error

2016-03-24 16:15:25.891 Zilingo[434:92251] *** Assertion failure in -[UIStoryboard instantiateViewControllerWithIdentifier:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3512.60.7/UIStoryboard.m:171
error: Execution was interrupted, reason: breakpoint 5.1.
The process has been returned to the state before expression evaluation.

Am I missing some step of the update ?

2ank3th
  • 2,948
  • 2
  • 21
  • 35

2 Answers2

1
Try to this format:-   

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

   // get your storyboard
   let storyboard = UIStoryboard(name: "Main", bundle: nil)

   // instantiate your desired ViewController
   let rootController = storyboard.instantiateViewControllerWithIdentifier("MyViewController") as! UIViewController

   // Because self.window is an optional you should check it's value first and assign your rootViewController
   if let window = self.window {
      window.rootViewController = rootController
   }

   return true
}
Lijith Vipin
  • 1,870
  • 21
  • 29
Mitul Marsoniya
  • 5,272
  • 4
  • 33
  • 57
0

I had the same issue. In my case I forgot to add identifier string. let vc = storyboard.instantiateViewControllerWithIdentifier("") as! UIViewController

I wrote like above. I forgot to add identifier. After I added identifier and it worked.

Narasimha Nallamsetty
  • 1,215
  • 14
  • 16