Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 6 - Template without Storyboards

Tags:

xcode

ios

I know this sounds trivial, but I'm quite irritated with the lack of an 'empty' template for iOS apps in beta 3/4.

I detest the Storyboard approach, (IMO it's naive to assume that it's always the most elegant approach).

In fact for the majority of my use cases, Storyboards simply don't work.

Can anyone advise me on how I can take the empty template and get to a starting point (app delegate with a window) without SB's? - or migrate one of the other templates to non SB.

that prepare for segue method gives me shivers it's so ugly...

Thanks in advance.

like image 663
Woodstock Avatar asked Jul 26 '14 17:07

Woodstock


Video Answer


2 Answers

I don't like Storyboards either.

Here is what I do to go from a SB-template to nice and clean 'from code design':

  • create a project from the single-view template (gives you the least storyboard 'boilerplaite')
  • delete the Storyboard
  • go to your AppDelegate(.m / .swift) and create a UIWindow through code in application:didFinishLaunchingWithOptions::

    CGRect screenBounds = [[UIScreen mainScreen] bounds];
    
    UIWindow *window = [[UIWindow alloc] initWithFrame:screenBounds];
    
    UIViewController *viewController = [[UIViewController alloc] init];
    [window setRootViewController:viewController];
    
    [window makeKeyAndVisible];
    
    [self setWindow:window];
    
  • remember to go select your target and delete the 'MainInterface' entry in 'General' under 'Deployment Info'

From this point on, you are ready to go and Xcode won't annoy you with SB anymore :)

Unfortunately, I haven't found a way to save a project as a template so far :/

like image 77
CodingMeSwiftly Avatar answered Oct 31 '22 02:10

CodingMeSwiftly


You probably don't want to just delete the file without telling the rest of the project..

You want to edit the plist and remove:

  • launch screen interface file base name
  • main storyboard file base name

That way, your app isn't looking for files that aren't there.

Then, add the code that Cabus says (which is just the code that Xcode used to provide in Xcode 5).

like image 42
Masa Avatar answered Oct 31 '22 01:10

Masa