compiling app for 10.6 and 10.7
compiling app for 10.6 and 10.7
- Subject: compiling app for 10.6 and 10.7
- From: Martin Hewitson <email@hidden>
- Date: Mon, 15 Aug 2011 19:38:41 +0200
Dear list,
I guess this is a really simple question to answer, but somehow my googling doesn't lead me to it.
I have an app and I want to include NSPopovers when the app runs on Lion. I have some run-time way of finding out if it is Lion or not (see below), but when the app runs on 10.6 I get errors like:
Symbol not found _OBJC_CLASS_$_NSPopover
I have the deployment target set to 10.6 in Xcode and the base sdk set to 10.7.
Am I doing something wrong? Is it possible to do what I want to do?
Cheers,
Martin
Here's the category methods on NSApplication which I based on some code I found on this list, I believe.
- (void)getSystemVersionMajor:(unsigned *)major
minor:(unsigned *)minor
bugFix:(unsigned *)bugFix;
{
OSErr err;
SInt32 systemVersion, versionMajor, versionMinor, versionBugFix;
if ((err = Gestalt(gestaltSystemVersion, &systemVersion)) != noErr) goto fail;
if (systemVersion < 0x1040)
{
if (major) *major = ((systemVersion & 0xF000) >> 12) * 10 +
((systemVersion & 0x0F00) >> 8);
if (minor) *minor = (systemVersion & 0x00F0) >> 4;
if (bugFix) *bugFix = (systemVersion & 0x000F);
}
else
{
if ((err = Gestalt(gestaltSystemVersionMajor, &versionMajor)) != noErr) goto fail;
if ((err = Gestalt(gestaltSystemVersionMinor, &versionMinor)) != noErr) goto fail;
if ((err = Gestalt(gestaltSystemVersionBugFix, &versionBugFix)) != noErr) goto fail;
if (major) *major = versionMajor;
if (minor) *minor = versionMinor;
if (bugFix) *bugFix = versionBugFix;
}
return;
fail:
NSLog(@"Unable to obtain system version: %ld", (long)err);
if (major) *major = 10;
if (minor) *minor = 0;
if (bugFix) *bugFix = 0;
}
- (BOOL) isLion
{
unsigned major, minor, bugFix;
[[NSApplication sharedApplication]
getSystemVersionMajor:&major minor:&minor bugFix:&bugFix];
if (major == 10 && minor == 7) {
return YES;
} else {
return NO;
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer
Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: email@hidden
WWW: http://www.aei.mpg.de/~hewitson
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden