Re: Framework versioning and handling multiple OS SDK's?
Re: Framework versioning and handling multiple OS SDK's?
- Subject: Re: Framework versioning and handling multiple OS SDK's?
- From: Brent Gulanowski <email@hidden>
- Date: Tue, 8 Sep 2009 18:25:08 -0400
For classes, you can check whether NSClassFromString(@"Classname") returns a
class.
For selectors, you can check whether NSSelectorFromString(@"selector")
returns a selector.
Usually that's enough. In fact, if you pick a representative class that was
introduced in the OS release of your choice, you can use that as a short cut
to check for the OS version. Or you can check the version major and minor
values using Gestalt for accurate version info:
file:///Developer/Documentation/DocSets/com.apple.adc.documentation.AppleSnowLeopard.CoreReference.docset/Contents/Resources/Documents/documentation/Carbon/Reference/Gestalt_Manager/Reference/reference.html
enum {
gestaltSystemVersion
<file:///Developer/Documentation/DocSets/com.apple.adc.documentation.AppleSnowLeopard.CoreReference.docset/Contents/Resources/Documents/documentation/Carbon/Reference/Gestalt_Manager/Reference/reference.html#//apple_ref/doc/c_ref/gestaltSystemVersion>
= 'sysv'
gestaltSystemVersionMajor
<file:///Developer/Documentation/DocSets/com.apple.adc.documentation.AppleSnowLeopard.CoreReference.docset/Contents/Resources/Documents/documentation/Carbon/Reference/Gestalt_Manager/Reference/reference.html#//apple_ref/doc/c_ref/gestaltSystemVersionMajor>
= 'sys1',
gestaltSystemVersionMinor
<file:///Developer/Documentation/DocSets/com.apple.adc.documentation.AppleSnowLeopard.CoreReference.docset/Contents/Resources/Documents/documentation/Carbon/Reference/Gestalt_Manager/Reference/reference.html#//apple_ref/doc/c_ref/gestaltSystemVersionMinor>
= 'sys2',
gestaltSystemVersionBugFix
<file:///Developer/Documentation/DocSets/com.apple.adc.documentation.AppleSnowLeopard.CoreReference.docset/Contents/Resources/Documents/documentation/Carbon/Reference/Gestalt_Manager/Reference/reference.html#//apple_ref/doc/c_ref/gestaltSystemVersionBugFix>
= 'sys3'
};
(Those symbols should link right into the file in your docs.)
Now, that's pretty awkward because you won't be able to instantiate a class
without converting from the classname or send a message without converting
the method sig and calling -performSelector: so I'd think the right way
would be to build two different versions of your framework and ship them
separately, making sure to version them so they can co-exist if necessary.
Not that hardly anyone does that.
On Tue, Sep 8, 2009 at 12:24 AM, aaron smith <
email@hidden> wrote:
> Hey All,
>
> I've got a framework (GDKit) that I maintain - started writing it on
> 10.5. I'm running into something I'm not sure how to handle.
>
> -So far, everything I've been writing in GDKit links against 10.5, and
> applications I've been writing link against GDKit, and 10.5.
> -I have some new classes I want to add to the framework, but some of
> the API's are in 10.6 only.
> -The new classes and features in my framework are optional - because
> they require 10.6, but I don't want to have to change all of my
> applications to require 10.6.
>
It is possible to build a framework against a different version of the OS
than an application that depends on it. Although you have to be careful
about setting up dependencies in Xcode which might push build settings from
the app down to the framework, if you use that feature of Xcode.
>
> What I'm trying to figure out is how to keep the framework compiling
> for 10.5, but optionally including the new features/classes when it's
> compiling for 10.6.
>
> There's just a few things I'm unclear of..
>
> -When it's compiling for 10.5, can I completely exclude files from
> compiling (the 10.6 features)? Is that the right way to exclude
> features?
>
Well it seems you're definitely going to have to build two versions of the
framework (probably by creating two different build configurations) -- in
the 10.5, yes, you won't compile/link those classes which require 10.6.
> -When I link against GDKit from an application, how can I have the app
> link against GDKit that include only the 10.5 features? Or optionally
> link against the build that includes the 10.6 features?
>
The linking is done dynamically. If you want the same compiled version of
your app to use different features of your framework depending on where it
is and what's available, it will have to explicitly check for the existence
of those things. Your app should just link against the framework, not a
specific version of it (if you choose to use versions).
If it all becomes too onerous to access 10.6-only classes/methods using
NSStringFrom... (or, in the case of Carbon/C, some other approach), you
would be better off building separate versions of your app.
>
> I've been reading about framework versioning, and what they recommend
> is creating a new major version. But that doesn't really help my
> problem - as creating a new major version would require the 10.6 SDK.
> Hopefully that makes sense.
>
> Does anyone know of any blog posts or tutorials about this particular
> situation?
>
> Any ideas would be sweet.
> _______________________________________________
I'm no expert in targetting multiple OS versions simultaneously, but these
are the strategies we use here. Hopefully this will help. (If I've made any
errors, I expect they'll get corrected.)
--
Brent Gulanowski
_______________________________________________
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