How to code using XCode 4.2 that support iOS 3.1.3

Actually, XCode 4.2 doesn’t support iOS 3.1.3 for simulator. But it can be used to deploy into iOS 3.1.3 device. I like to use XCode 4.2 to develop the code because it has better interface and ‘Interface Builder’ already built in there.

Here is what i did :

  1. You may need to add iOS 3.1.3 sdk folder into XCode development folder
  2. New Project, I Choose ‘Empty Application’ , Uncheck option ‘Use Automatic Reference Counting’
  3. On file ‘Info.plist’, remove key ‘Required Device capabilities’
  4. in main.m , replace the code :
    1
    2
    3
    
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
     }

    with :

    1
    2
    3
    4
    
        NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
        int retVal = UIApplicationMain(argc, argv, nil, nil);
        [pool release];
        return retVal;
  5. In AppDelegate.h , replace the code:

    1
    2
    3
    
    @interface AppDelegate : UIResponder 
     
    @property (strong, nonatomic) UIWindow *window;

    with :

    1
    2
    3
    4
    5
    
    @interface AppDelegate : NSObject  {
        UIWindow *window;
    }
     
    @property (nonatomic, retain) IBOutlet UIWindow *window;
  6. In AppDelegate.m , Add this method :
    1
    2
    3
    4
    5
    
    - (void)applicationDidFinishLaunching:(UIApplication *)application {    
     
    	// Override point for customization after application launch
        [self.window makeKeyAndVisible];
    }
  7. go to the target ‘Build Settings’, under ‘Deployment’ , set ‘iOS Deployment Target’ to ‘iOS 3.1’
  8. on ‘Build Settings’, under ‘Architectures’, select ‘Architectures’ and click ‘+’ to add architecture, type in ‘armv6’
  9. Where is MainWindow.xib ? In Xcode 4.2 the MainWindow.xib is not included for some of the project templates so we reconstruct the MainWindow.xib (thanks to Saurabh) :
    a) File > New File , choose iOS > User Interface > Window, name it as ‘MainWindow’
    b) Change the Class of File’s Owner to UIApplication
    c) drop a Object from Library, change the class of that Object to ‘AppDelegate’
    d) Bind delegate in File’s Owner to AppDelegate object
    e) Control-Drag from the window outlet of the AppDelegate Object to the Window
    f) Navigate to the project, and in the Summary tab, select MainWindow as the Main Interface
  10. The template is done! You can continue your code (which is support to iOS 3.1.3) and debug it quickly using iPhone 5 Simulator.

After all of these settings, we can deploy it on iOS 3.1.3 device, and simulate it using iPhone 5 simulator.

I Hope this post can be a helpful information for you.

About Thomas G

Thomas G is a founder and editor of Evenbright. He is a tech entusiast. Currently he is working as a Senior Software Developer in a travel company.

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*