10

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.

Woodstock
  • 22,184
  • 15
  • 80
  • 118
  • Just curious, what 'use cases' do you talk about that storyboards are not an option? And why detest the `prepareForSegue:` method? – duci9y Jul 26 '14 at 17:16
  • 1
    @duci9y - Sure, I prefer a programmatic approach. I like to do things in code. For large complicated projects with (for example) 20+ VC's Storyboarding is simply inelegant, and, I find, counterproductive. Regarding prepareForSegue... well, IMO I think it's suggested usage is completely bad coding practice. How about the way you use a 'magic' string to reference which VC you are transitioning to!? I much prefer to create my viewController and present/push it as required. Imagine having potentially 20 different VC's referenced by name in prepareForSeague. What a completely disgusting paradigm. – Woodstock Jul 26 '14 at 17:21
  • @duci9y Can you imagine what the SB looks like with 20/30 viewControllers though? - It just doesn't work! It's grand for little projects but it's not effective for anything larger. – Woodstock Jul 26 '14 at 17:24
  • For me, visual cues as to the hierarchies of my app are better than just a mental image. Just saying. – duci9y Jul 26 '14 at 17:25
  • @JohnWoods At the scale of 20-30 view controllers, you should probably be using separate storyboards depending on the flow. Also, I'm not sure why you'd be launching 20-30 different view controllers from a single view controller. You might want to look at your code structure. – ray Jul 26 '14 at 17:27
  • @ray I agree, it was just an example, but either way I really don't like storyboards. The above example is not their only drawback. – Woodstock Jul 26 '14 at 17:30
  • 1
    just imagine you want to design a custom container ... storyboard have the 'containerView' object sure, but all you can ever build through that are the simplest containments. Another major drawback for me is the splitting of UI-code: There are some things you just CAN NOT set in IB, so you'll have to set those in code (all CALayer things, etc.) - now then you set some things in code and some things in IB, you'll always have to think 'hmm, where did i set this?' - just not productive for me. However, Xcode6 added @IBDesignable, which is a cool feature imo, but thats about it with SB for me ;) – CodingMeSwiftly Jul 26 '14 at 17:34
  • @Cabus A storyboard container view will hold a complete, fully functional view controller. You can either use an `embed` segue, or a separate xib. – ray Jul 26 '14 at 17:38
  • 1
    It will for sure! What I'm saying is that it is not suitable for more complex containments. - maybe I'm just not experienced enough with IB, but that's what my impression was when exploring the storyboard when i started developing for iOS. - I guess @duci9y hit the nail right on the head: To each his own ;) – CodingMeSwiftly Jul 26 '14 at 17:42
  • Create your template and upload it to github! – Eyeball Nov 24 '14 at 20:07

3 Answers3

25

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 :/

CodingMeSwiftly
  • 3,231
  • 21
  • 33
  • 1
    Instant +1 for "I feel you bro" – Brian Tracy Sep 20 '14 at 22:02
  • 2
    yet, .pch file will be missing. what you can do is, `1) create a header file with whichever name.pch` `2) Project Setting->Apple LLVM 6.0 - Language->Precompile Prefix Header(YES)` `3) Put the path of Prefix Header. Ex) As of xCode 6, $SRCROOT/$PROJECT_NAME/Info.pch.` – Yoon Lee Oct 13 '14 at 17:26
  • 1
    @YoonLee -- it's true that if you want PCHs, you will have to create them manually, although they are not required and may not even be recommended in all cases, e.g., see [this StackOverflow thread](http://stackoverflow.com/questions/24158648/why-isnt-projectname-prefix-pch-created-automatically-in-xcode-6). – Matt Jan 03 '15 at 17:19
4

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).

Masa
  • 520
  • 5
  • 13
2

There's a github library for xcode 7 project template without storyborad, which followed Cabus answer.

https://github.com/elprup/xcode7-project-template

elprup
  • 1,960
  • 2
  • 18
  • 32
  • I am a visual person but I find storyboards to be confusing. My apps ask for screen boundaries to set up layouts and have survived from iPhone 4 to 6s without needing updates. Thanks for this link. – ManInTheArena Jan 29 '16 at 20:02