Running Game Center app on 3.x?

Discussion in 'Public Game Developers Forum' started by lazypeon, Nov 9, 2010.

  1. lazypeon

    lazypeon Well-Known Member
    Patreon Bronze

    I'd like to include Game Center support for devices with iOS 4.1 or higher. As far as I can tell, the only way I can compile using the GameKit classes is with Base SDK 4.1. When I select Base SDK 3.X, even with the GameKit framework included, my app will no longer compile because the GK classes are missing.

    My question is: if I compile with the 4.1 SDK, will 3.X devices be able to run the application (minus the Game Center support, of course)? Since I don't have a 3.X device, I have no way to really test if it works or not. I'd like to make sure 3.X is supported since a lot of people haven't upgraded, but I also want to include Game Center support for devices that have it.
     
  2. Golden Hammer

    Golden Hammer Well-Known Member

    Dec 1, 2009
    107
    0
    0
    Indie Game Developer
    Boston
    #2 Golden Hammer, Nov 9, 2010
    Last edited: Nov 9, 2010
    Base SDK is what you link against. You want that to be 4.1. iOS deployment target is the minimum system requirement, you'd want that at 3.0.

    You'll need to weak link the gamecenter framework, and check the OS version before calling any of the functions.


    NSArray* versionComponents = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:mad:"."];
    NSString* majorVersionString = (NSString*)[versionComponents objectAtIndex:0];
    int majorVersionNumber = [majorVersionString intValue];
    if (majorVersionNumber > 3) {
    if (majorVersion == 4) {
    // you probably want to check to see if the array has at least two values.
    NSString* minorVersionString = (NSString*)[versionComponents objectAtIndex:1];
    int minorVersionNumber = [minorVersionString intValue];
    if (minorVersion > 0) mSupportsGameCenter = true;
    }
    else {
    mSupportsGameCenter = true;
    }
    }
     
  3. Ozden79

    Ozden79 Well-Known Member

    Dec 29, 2009
    313
    9
    18
    If you weak reference GameKit, than you can compile against 4.1 and run at 3.X. You need to set the target version to 3.0 though.

    In GameCenter codes side, if you use OpenFeint for integration, you don't have to do anything but if you reach GameCenter directly using your own codes, you need to check whether you can create GameKit classes or if the iOS version is 4.1 and higher and than run these codes so your game don't get crashed on 3.X devices.
     
  4. lazypeon

    lazypeon Well-Known Member
    Patreon Bronze

    Ahhh -- I had read about the weak linking, but I totally missed the deployment target. I assumed if I set the BaseSDK version that it would require the target device to have that version too. I do see the 'Deployment Target' now, in the build settings. Makes total sense.

    Thanks a bunch for the help!
     

Share This Page