> Hi,
>
[quoted text clipped - 3 lines]
> runtime checking? SDKs require you to compile individual applications
> to run on the desired versions of Mac OS X.
If you just want to make sure you can run on 10.2, linking against the
10.2 SDK gets you almost all the way there. If you actually want to
leverage more advanced tools if they're available without requiring
them, check into the docs provided on the subject of weak-linking. And
yes, you'll need to check that a function has resolved before using it
in that case.

Signature
Goal 2005: Convincing James Hetfield to cover the Strawberry Shortcake
"Are You Berry Berry Happy?" song.
> I am developing an application on a 10.3 computer to run on 10.2+. Is
> there a way to make a single executable that would run on 10.2, 10.3
> and 10.4? (I necessary, I can use a 10.4 computer.) Do I need to do
> runtime checking? SDKs require you to compile individual applications
> to run on the desired versions of Mac OS X.
Actually, this is not the case. You build against the SDK for the
highest version of the operating system whose functionality you want to
ues, and you set the "Mac OS X Deployment Target" build setting to the
lowest version of the operating system you want to run on.
Thus if you want to build an application that takes advantage of 10.3
features and also runs on 10.2, you would build against a 10.3.x SDK
and set your Mac OS X Deployment Target to 10.2. All 10.3 APIs will be
weak-linked, meaning that you will need to check whether you're running
on 10.3 or later before calling or otherwise using them.
-- Chris
Patrick Machielse - 17 Oct 2005 23:17 GMT
> > I am developing an application on a 10.3 computer to run on 10.2+. Is
> > there a way to make a single executable that would run on 10.2, 10.3
[quoted text clipped - 12 lines]
> weak-linked, meaning that you will need to check whether you're running
> on 10.3 or later before calling or otherwise using them.
But be aware that not all of Mac OS X api's support weak linking. If you
reference a symbol that is not available in 10.2, and which is not weak
linked, your app will crash at startup before you can check anything
(unless you take special measures). So while weak linking is useful, in
the end the only way to find out if your program works is to test it
well on all target systems.
patrick
wisefamily@integrity.com - 18 Oct 2005 16:49 GMT
> > I am developing an application on a 10.3 computer to run on 10.2+. Is
> > there a way to make a single executable that would run on 10.2, 10.3
[quoted text clipped - 12 lines]
> weak-linked, meaning that you will need to check whether you're running
> on 10.3 or later before calling or otherwise using them.
How do you check if you are on 10.3 or later? I couldn't find any
documentation on it.
Thanks again,
David
Michael Ash - 18 Oct 2005 19:31 GMT
>> > I am developing an application on a 10.3 computer to run on 10.2+. Is
>> > there a way to make a single executable that would run on 10.2, 10.3
[quoted text clipped - 15 lines]
> How do you check if you are on 10.3 or later? I couldn't find any
> documentation on it.
Do you actually want to see if you're on 10.3, or do you want to check for
the existence of a certain API/function/class?
If the latter, you do so by weak-linking in the case of functions, or by
using NSClassFromString() in the case of ObjC classes instead of referring
to the classes directly in the code.
If you really need to check the actual OS version, use the Gestalt()
function.

Signature
Michael Ash
Rogue Amoeba Software
wisefamily@integrity.com - 18 Oct 2005 20:12 GMT
> >> > I am developing an application on a 10.3 computer to run on 10.2+. Is
> >> > there a way to make a single executable that would run on 10.2, 10.3
[quoted text clipped - 18 lines]
> Do you actually want to see if you're on 10.3, or do you want to check for
> the existence of a certain API/function/class?
I am trying to check if a function, class, or API exists
> If the latter, you do so by weak-linking in the case of functions, or by
> using NSClassFromString() in the case of ObjC classes instead of referring
> to the classes directly in the code.
How do you weak-link?
Thanks,
David
Michael Ash - 18 Oct 2005 21:47 GMT
>> >> > I am developing an application on a 10.3 computer to run on 10.2+. Is
>> >> > there a way to make a single executable that would run on 10.2, 10.3
[quoted text clipped - 26 lines]
>
> How do you weak-link?
A Google search for "weak link site:apple.com" turns up this site:
http://developer.apple.com/documentation/MacOSX/Conceptual/BPFrameworks/Concepts
/WeakLinking.html
As well as a bunch of others if that one doesn't meet your needs.

Signature
Michael Ash
Rogue Amoeba Software
wisefamily@integrity.com - 19 Oct 2005 03:54 GMT
> >> >> > I am developing an application on a 10.3 computer to run on 10.2+. Is
> >> >> > there a way to make a single executable that would run on 10.2, 10.3
[quoted text clipped - 36 lines]
> Michael Ash
> Rogue Amoeba Software
Thank you for your help. However, there is one thing I forgot to
mention: I am using Cocoa. Does anyone know how to weak link a method?
To you check the existence of the selector like this:
SEL selector = @selector(weakLinkSelector:);
if (SEL != NULL) {
// Selector exists
} else {
// Selector does not exist
}
Thanks again,
David
Michael Ash - 19 Oct 2005 09:20 GMT
>> A Google search for "weak link site:apple.com" turns up this site:
>>
[quoted text clipped - 12 lines]
> // Selector does not exist
> }
Selectors always exist. What you want to check is whether a given
object responds to it. YYou would do it like this:
if([theObject respondsToSelector:selector])
...
That's assuming that the class you want to use exists on all OS versions
you're targetting. If it doesn't, then you (also?) have to check for the
existence of the class, and never refer to it directly. Instead of:
obj = [[NSOnlyOnPantherPlus alloc] init];
Do:
Class NSOnlyOnPantherPlusPtr = NSClassFromString(@"NSOnlyOnPantherPlus");
if(NSOnlyOnPantherPlusPtr)
obj = [[NSOnlyOnPantherPlusPtr alloc] init];
else
...doesn't exist...
Note that this is not strictly weak linking, but is rather using the ObjC
runtime to achieve similar results.

Signature
Michael Ash
Rogue Amoeba Software
Sherm Pendley - 19 Oct 2005 10:33 GMT
> Thank you for your help. However, there is one thing I forgot to
> mention: I am using Cocoa. Does anyone know how to weak link a method?
> To you check the existence of the selector like this:
>
> SEL selector = @selector(weakLinkSelector:);
> if (SEL != NULL) {
To check for a method:
if ([someObject respondsToSelector:selector]) {
// yadda
}
To check for a whole class:
if (NSClassFromString(@"ClassName")) {
// yadda
}
sherm--

Signature
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
wisefamily@integrity.com - 19 Oct 2005 16:49 GMT
Thank you all for your help! I think I understand it now.
Thanks again,
David