What is the use of Main Interface option in the build settings for iOS application?
cocoa-touch, ios, iphone, objective-c, xib
Solution
I found out how to do this. It was very obvious after I understood the whole process of how the application is loaded. So I thought I'll answer my own question.
The key is to initialize the window and set up the `UIApplication` and its delegate from the xib itself.
- Step 1: Create an xib with a `UIWindow` object in it. Make the file's owner of the xib as `UIApplication`.
- Step 2: Create an `AppDelegate` object in the xib and connect the file's owner's `delegate` outlet to this object.
- Step 3: Create an outlet for the window in the `AppDelegate` class.
- Step 4: Select the MainInterface option in build settings as the xib you created.
- Step 5: Comment out the code in `applicationDidFinishLaunchingWithOptions:` method.
If you run the program it will show the window in the simulator, but you'll get a warning that application is supposed to have a `rootViewController` at the end of application launch.
- Step 6: So inside `applicationDidFinishLaunchingWithOptions:` we can instantiate a `UIViewController` and assign the window outlets rootViewController as this view controller.
Problem
When I start a single view application and instead of assigning the `rootViewController` programmatically from `AppDelelgate`, try to use the 'Main Interface' option to assign a `xib` as my main interface file, a `SIGABRT` signal is sent to the program when I run it. Why does this happen? What is the purpose of the 'Main Interface' option?