Re: compiling app for 10.6 and 10.7
Re: compiling app for 10.6 and 10.7
- Subject: Re: compiling app for 10.6 and 10.7
- From: David Duncan <email@hidden>
- Date: Mon, 15 Aug 2011 10:45:40 -0700
On Aug 15, 2011, at 10:38 AM, Martin Hewitson wrote:
> 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?
What compiler are you building with? Clang should automatically weak-link this class for you, but GCC (and GCC-LLVM) don't know how to do so and as such you would need to use NSClassFromString() to obtain the NSPopover class instead of referencing it directly.
In either case, the best general way to determine availability of weak-linked implementations is to test for them directly rather than using a system version check (like gestalt). If your using Clang (which I suspect you are not given your error) you could just use:
"if ([NSPopover class]) { /* do stuff with popovers */ } else { /* do stuff without */ }"
In GCC you should use
Class nsPopover = NSClassFromString(@"NSPopover");
if (nsPopover) ...
--
David Duncan
_______________________________________________
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