Compiling for iOS 3.1.3 with Xcode 4.2

1.9k Views Asked by At

Does Xcode 4.2 support compiling projects for iOS 3.1.3? I tried compiling a project that I'm currently working on, and I keep getting crashes every time I try running the application on an iPhone 3G with iOS 3.1.3. I know that the OS I'm running on is outdated already, but the client required that the application should run on iOS 3.1.3. Any ideas how will I solve this problem?

2

There are 2 best solutions below

3
On

In Build Settings changes following settings:

  1. Base SDK -> Lastest iOS (iOS 5.0)
  2. iOS Deployment Target -> iOS 3.1
  3. Architectures -> choose other... and manual add "armv6"
  4. Valid Architectures -> remove "armv7", just leave "armv6"

In *AppDelegate.m

- (bool)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease];
    // Override point for customization after application launch.
    self.viewController = [[[MyHudDemoViewController alloc] initWithNibName:@"MyHudDemoViewController" bundle:nil] autorelease];

    // NOTE THIS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    // iOS 3.1 don't support the following statement.
    //self.window.rootViewController = self.viewController;
    [self.window addSubview:self.viewController.view];

    [self.window makeKeyAndVisible];
    return YES;
}

Uh....SORRY... forgot one...

  1. Check your project's Info.plist, if it has the "Required device capabilities" item, then change the item from "armv7" to "armv6".
0
On

Here are a whole bunch of things I had to do to make XCode 4 compile for iOS 3.1 AND debug on a 3G iPhone:

  • Downgrade to XCode 4.3.3.

    Xcode 4.5.2 would simply refuse to connect to an iPhone 3G for debugging. The 4.3.3 version happily coexists alongside the 4.5.2, they can even share the same project file, although leaving the armv7s in the architecture settings will generate innocuous warnings in 4.3.3. See below.

  • Change the project settings

    Architecture -> go to "others", remove the line, put armv6 armv7 
    

    (you can also add armv7s in the line above for compiling the same project with 4.5.2, but it will generate warnings under 4.3.3)

    Valid architecture -> armv6 armv7 armv7s
    
    Deployment target -> change to 3.1
    
  • In the plist file, in "Required device capabilies", remove armv7.

  • Change the Target settings (click target on the left pane)

    deployment target to 3.1

  • Edit your Scheme to change the debugger

    In the Run section, debug, change debugger to GDB (instead of LLDB)

    In the Test section, debug, change debugger to GDB (instead of LLDB)

  • Change the auto-generated code that will crash an iOS 3.1 app

    In your AppDelegate "didFinishLaunchingWithOptions", instead of this line

    self.window.rootViewController = self.viewController;

    Put this code

    if ([self.window respondsToSelector:@selector(setRootViewController:)])
    self.window.rootViewController = self.viewController;
    else
    [self.window addSubview:self.viewController.view];
    

    And then you should be able to run and debug on a 3G iPhone.