2.7. Removing Interface Builder from a Project

If you don't plan on using Interface Builder in a particular project, you can remove support for it entirely from the project. Instructions to accomplish this follow. After following these steps, your project will no longer use Interface Builder NIB files to obtain any of its information about the default layout of your UIs. This means you'll need to code in support for windows, views, and other objects yourself. The next chapter will guide you through these objects. You'll still be able to instantiate views from NIB files using the NIB-specific initialization methods you'll learn.



Interface Builder is a matter of personal preference. Many developers like it because it allows them to create UIs in a WYSIWYG environment. Others find it cumbersome, and prefer having all of their UI objects clearly defined in their source code. Some aspects of Interface Builder have been reportedly buggy, so you'll want to know how to create certain objects if you run into problems.

  1. Open your new window-based application and expand the Resources folder in the project. You'll then see one or more files with an .xib extension, such as MainWindow.xib. Right-click each file and select Delete from the pop-up menu. This will delete all Interface Builder templates from the project.

  2. Within the Resources folder, you'll also see a file named Info.plist. Click this file to open it. A property list window will open containing information about your application. At the bottom, you'll see a property key named Main nib file base name. Click on this property and press the delete key to delete it from your project, then save your changes. This causes your application to load without requiring an Interface Builder file.

  3. Now that you've detached Interface Builder from your application, you'll need to manually specify the name of the application delegate class. This is the class whose applicationDidFinishLaunching method will be notified when your application starts up, and is where your UI code will begin. You can find the name of your project's delegate class underneath the Classes folder in your project. Its name will be the name of your project suffixed with AppDelegate. For example, if you named your project Wizbang, the name of your delegate class should be WizbangAppDe⁠leg⁠ate. Expand the Other Sources folder in your project and edit the file named main.m. Edit the line calling UIApplicationMain to reflect the name of your delegate class. An example follows:

    int retVal = UIApplicationMain(argc, argv, nil, @"WizbangAppDelegate");

You can also remove the property and synthesize directives from your classes. We left them in our examples in case you'd like to make them work with Interface Builder templates.