Nibless iOS App


I always believe in the right tool for the job, so I’m not an Interface Builder hater per se, but I find it a little pathetic how infrequently IB is the right tool for the job. In addition, I’ve found IB to be at its worst whenever the development team is bigger than one. Don’t panic, just go nibless.

It’s very easy to go completely nibless (and a little stylish in my opinion) and eschew Interface Builder altogether. For all you Flexers out there, this is the moral equivalent of eschewing Flash Builder’s Design View. Honestly, who really uses Design View to build an app beside Adobe evangelists doing 30 minute demos?

A Completely Nibless App

Here’s how you can build a completely nibless app in five simple steps. First, you’ll want to start with a fresh Window-based Application in Xcode. Then follow these steps:

  1. Remove MainWindow from your app’s Info.plist
  2. Delete all .xib files
  3. Edit AppDelegate.h remove all the IBOutlet keywords
  4. Edit main.m, import AppDelegate.h, and set the UIApplicationMain‘s 4th parameter to @"AppDelegate"
  5. Edit AppDelegate.m to instantiate the main UIWindow in code

Here’s what main.m should look like after you’ve completed Step 4:

#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char *argv[]) {
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    int retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate");
    [pool release];
    return retVal;

And here’s what the application:didFinishLaunchingWithOptions: method in AppDelegate.m should look like:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
    [self.window makeKeyAndVisible];
    return YES;

Now you can go about you view-creation business in a nibless fashion. I’d probably create a UIViewController subclass as my root view, construct my UI in loadView, and wire everything together in the AppDelegate.

Nibless App Xcode Template

But don’t do any of that stuff! Instead you can just use this handy-dandy Xcode template to do all the work. On of the very few things Xcode gets right is its template system. It is very easy to create a custom template for Xcode (see here and here for the basics).

Install the NiblessApp custom template in Xcode:

  1. Download nibless_app_template.tgz
  2. cd ~/Library/Application Support/Developer/Shared/Xcode/Project Templates/ (you might need to create the Project Templates folder if it doesn’t already exist)
  3. tar xzvf /path/to/nibless_app_template.tgz
  4. Quit Xcode and restart




Thanks for writing this up. One small change – it should be screen bounds not frame when initializing the UIWindow.

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
© 2021