Dr.Kameleon
Dr.Kameleon

Reputation: 22820

Different versions of Cocoa app for different OS X versions

Is it possible to create one binary and, according to the OS X version, have it behave differently?

Any ideas (Cocoa- and Xcode- friendly) on how this could be achieved?

Upvotes: 0

Views: 71

Answers (2)

Daij-Djan
Daij-Djan

Reputation: 50099

Wain got that right.. use one app and have it load bundles based on the OS version

something like

int main(args) {
   NSBundle *bundle = nil;
   if(osVersion < 10.5)
          bundle = [NSBundle bundleWithURL:pathToBundleFor105InAppsBundle];
   else
          bundle = [NSBundle bundleWithURL:pathToBundleFor106andUpInAppsBundle];

   [bundle load];

   Class appDelegateClass = NSClassFromString(@"AppDelegateClass");
    DDAppDelegate = [[appDelegateClass alloc] init];
    [[NSApplication sharedApplication] setDelegate:DDAppDelegate];
    status = NSApplicationMain(argc, (const char **)argv);       
}

Upvotes: 1

Wain
Wain

Reputation: 119031

The main executable for your application can be a small program which runs on all versions, interrogates the OSX version and then either loads a bundle which contains the version of the application desired or starts a second executable which is bundled into the application package.

The bundle loading option should be easier to do and look slicker from as user perspective as only a single application would be running. Using the other approach one application would start and then close while starting another so it's likely to have a visual side effect.

Upvotes: 2

Related Questions