Re: Base SDK 10.6 deployment target 10.5 - symbol not found
Re: Base SDK 10.6 deployment target 10.5 - symbol not found
- Subject: Re: Base SDK 10.6 deployment target 10.5 - symbol not found
- From: Wim Lewis <email@hidden>
- Date: Tue, 11 Jan 2011 10:40:29 -0800
On 10 Jan 2011, at 11:42 PM, Kenneth Baxter wrote:
> Hi, I have a project I'm working on which needs to run on 10.5 and 10.6. I have various things enabled or disabled using:
>
> if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5) ...
>
> but I also have some places in my code where I want to use a CAShapeLayer subclass in 10.6 and an alternate version based on NSViews in 10.5. My logic says it is not going to call the CAShapeLayer, but it appears that it has been linked in to the application anyway, so when I try to run the program on 10.5, it gives me the error:
>
> dyld: Symbol not found: _OBJC_CLASS_$_CAShapeLayer
>
> What is the proper way to handle situations where a whole class is missing in the earlier SDK like this? The documentation doesn't seem to address this scenario as far as I can see.
You might be able to weakly link the class, in which case dyld will not complain but messages to CAShapeLayer will return nil. I don't remember on which OS revs it became possible to weak link a class, though. (Weak linking C symbols has been possible since 10.2; see TN2064.)
The older technique is to avoid class-name literals and use NSClassFromString() to get a reference to the class object:
Class shapeLayer = NSClassFromString(@"CAShapeLayer");
blahblah = [[shapeLayer alloc] init...];
If CAShapeLayer isn't linked into your process, then NSClassFromString() will safely return Nil. You can test for that or you can check NSAppKitVersionNumber.
_______________________________________________
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