I found this fantastic answer that will be helpful and this one that is specific to swift.
The steps to follow are:
Put a StoryBoard ID on the 2 possible initial screens.
From the StoryBoard do not select any StoryBoard as initial and if you already have it selected, uncheck it.
At this point, check that if you launch the application the warning appears:
Failed to instantiate the default view controller for UIMainStoryboardFile 'MainStoryboard' - perhaps the designated entry point is not set?
And the initial screen is nil
.
If this is not the case, you have forgotten to unmark the initial StoryBoard.
If everything goes well here we continue:
Go to the preferences of the application and:
3.1 preferences - > target - > Info. There eliminates the value of the variable Main storyboard file base name
.
3.2 In the tab General
removes the value of Main Interface
(this eliminates the warning above).
Now we differentiate point 4 (without swift
) and point 5 (with swift
)
[WITHOUT SWIFT] In application:didFinishLaunchingWithOptions:
you can already create the initial window:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *viewController = // determine the initial view controller here and instantiate it with [storyboard instantiateViewControllerWithIdentifier:<storyboard id>];
self.window.rootViewController = viewController;
[self.window makeKeyAndVisible];
return YES;
}
[WITH SWIFT]
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
var exampleViewController: ExampleViewController = mainStoryboard.instantiateViewControllerWithIdentifier("ExampleController") as! ExampleViewController
self.window?.rootViewController = exampleViewController
self.window?.makeKeyAndVisible()
return true
}