Re: "weak link" framework refs for 10.1 compatibility?
Re: "weak link" framework refs for 10.1 compatibility?
- Subject: Re: "weak link" framework refs for 10.1 compatibility?
- From: Bill Cheeseman <email@hidden>
- Date: Fri, 08 Nov 2002 05:17:25 -0500
on 02-11-07 2:20 PM, Dan Wood at email@hidden wrote:
>
I'm trying to add some AddressBook framework and NSAppleScript
>
functionality to my app, but still allow for 10.1 compatibility. I'm
>
making sure that no 10.2-specific methods get called in my code, and
>
that's straightforward, but what is a problem is the constants (e.g.
>
the Address Book constants in ABGlobals.h, or
>
NSAppleScriptErrorMessage) are declared within the frameworks, that
>
cause the bundle not to load in 10.1.
>
>
I've found a workaround is to use my own string constants -- e.g.
>
@"NSAppleScriptErrorMessage" instead of NSAppleScriptErrorMessage --
>
but that seems like such a hack. Is there a better way around this
>
problem, like some sort of "weak linking" (for lack of a better term)
>
that will cause the code not to complain that it can't find the string
>
constants in the 10.1 frameworks, since the code will never be executed?
I recently explored these issues in depth with an Apple engineer. The
results of my inquiry are written up in the last chapter of my forthcoming
book, "Cocoa Recipes" (Vermont Recipes), due on bookstore shelves within a
few weeks (officially next week).
The bottom line, as I understand it, is that an application using C
constants that are new in 10.2 will not launch in 10.1.x or earlier.
Checking the system version to branch around them will not work, because the
loader tries to load them all at once, up front. One sure-fire way to deal
with this is to launch a very small faceless app first to check the system
version, then launch the 10.2 app only if it's running under 10.2. I'm not
sure there is any other workaround. In the future, there will be; for
example, when running a 10.3 app under 10.2. But 10.2 may be the lowest
version that you can fall back to in this kind of situation, because its the
first version in which weak linking is supported.
New C functions are treated differently by the loader. You can normally
branch around them by checking the system version.
This issue affects the AddressBook frameworks and possibly one or two
others. DiscRecording comes to mind. The easiest solution is to put up an
alert at launch time saying your app won't run under any system older than
10.2. This may not be a realistic option for everybody.
I haven't tried this, but it occurs to me that you could try isolating your
Address Book code in a separate framework, and have your application load it
only if you're running under 10.2 or newer.
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
The AppleScript Sourcebook -
http://www.AppleScriptSourcebook.com
Vermont Recipes -
http://www.stepwise.com/Articles/VermontRecipes
Croquet Club of Vermont -
http://members.valley.net/croquetvermont
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.