Re: Tips to deploy applications to multiple Mac OS X versions

2008-04-10 Thread Steve Christensen

On Apr 9, 2008, at 11:08 PM, Ben Lachman wrote:

On Apr 9, 2008, at 3:27 PM, David Duncan wrote:

On Apr 9, 2008, at 7:43 AM, Lorenzo Bevilacqua wrote:

I'm trying to build a Cocoa application so that it can run on Mac  
OS X from version 10.3.9 to 10.5.
I have 10.5 installed so the application runs fine on my system  
and on other Leopard systems.
I haven't build a project for multiple platforms yet, so I tried  
to duplicate the main Xcode target and set different deployment  
target settings like


Typically you would only use 1 target. Use the SDK to the OS whose  
API your are targeting (such as the 10.5 SDK). Then set the  
deployment target to the minimum version you wish to run on  
(example, 10.3). Finally, you would do runtime checks for API  
availability.


This is totally true.  Multiple binaries make unhappy users. Of  
course buggy cross-version binaries make unhappy users too.


- Is there a way to differentiate part of code by platform? I  
remember I saw in some files lines like this


#if MACOSX_DEPLOYMENT_TARGET == MAC_OS_X_VERSION_10_4
#endif

is this correct?


This is a compile time check. Generally it is appropriate if you  
plan to ship a binary with a specific compile-time dependency. It  
sounds like you really want a run time check, which requires you  
to check for the availability of the features you are trying to  
use. How you check for this will depend on what you are doing to  
some degree.



To elaborate:

Your code will have checks like this in it:

if( [someObject respondsToSelector:@selector 
(niftyLeopardFeatureMethod:)] )

[someObject niftyLeopardFeatureMethod:anotherObject];
else
// handle the 10.4 and/or 10.3.9 case


Actually, what I find to be a better arrangement is something like this:

#if MACOSX_DEPLOYMENT_TARGET  MAC_OS_X_VERSION_10_5
if (![someObject respondsToSelector:@selector 
(niftyLeopardFeatureMethod:)])

{
// handle the pre-10.5 case here
}
else
#endif
{
// handle the 10.5+ case here
}

Picky, perhaps, but the benefit is that the check for existence of a  
10.5 feature, plus the code that handles the older OS versions, is  
inside a compile-time conditional. If you later change your  
deployment target to 10.5, all the older OS pieces are compiled out.  
You can also easily search your sources for  
MACOSX_DEPLOYMENT_TARGET to find your legacy code.


One caveat, though, is that you should probably have a runtime check  
for the minimum OS version you expect so that you don't end up with a  
crash if someone tries to use your nifty Leopard features on Tiger.  
Adding something to main() would probably be easiest, either checking  
against NSAppKitVersionNumber or calling Gestalt() to get the OS  
version.


steve

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Tips to deploy applications to multiple Mac OS X versions

2008-04-10 Thread Ben Lachman


On Apr 10, 2008, at 6:19 PM, Chris Suter wrote:
One caveat, though, is that you should probably have a runtime  
check for the minimum OS version you expect so that you don't end  
up with a crash if someone tries to use your nifty Leopard  
features on Tiger. Adding something to main() would probably be  
easiest, either checking against NSAppKitVersionNumber or calling  
Gestalt() to get the OS version.


There's something you can put in the Info.plist that does this for  
free. I forget exactly what it is but I'm sure it's easily found.


LSMinimumSystemVersion is the key.

--
Ben Lachman
Acacia Tree Software

http://acaciatreesoftware.com

[EMAIL PROTECTED]
740.590.0009

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Tips to deploy applications to multiple Mac OS X versions

2008-04-10 Thread Jerry Krinock

On Apr 9, 2008, at 11:08 PM, Ben Lachman wrote:

On Apr 9, 2008, at 3:27 PM, David Duncan wrote:


Typically you would only use 1 target. Use the SDK to the OS whose  
API your are targeting (such as the 10.5 SDK). Then set the  
deployment target to the minimum version you wish to run on  
(example, 10.3). Finally, you would do runtime checks for API  
availability.



That's fine if the classes exist in all the OS versions, but more  
commonly you'll want to use complete classes that are not available in  
earlier SDK, of which there are many, especially in Leopard.  Code  
instantiating such classes must be put in separate bundles that are  
loaded when the user activates a Tiger/Leopard-only feature that  
requires instantiating a Tiger/Leopard-only class.  It's another hoop  
you have to jump through.  Also, when you encounter obscure bugs in  
10.3, no one can help you because no one remembers them and no one  
cares.


This is totally true.  Multiple binaries make unhappy users. Of  
course buggy cross-version binaries make unhappy users too.



And unhappy programmers.  My estimate is that supporting 10.3-10.5  
increases my development + testing + bug-fixing time increases by a  
factor of 1.5 over what it would be if it was 10.5 only, plus the  
penalty that I simply forego some features which are not practical to  
implement or disable in 10.3, and not worth the time to split off into  
my Tiger bundle.


I recommend that you explain to your requirments guru(s) the high cost  
of 10.3-10.5 support and ask them to reconsider if you really need to  
do this, Lorenzo.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Tips to deploy applications to multiple Mac OS X versions

2008-04-10 Thread Michael Ash
On Fri, Apr 11, 2008 at 12:26 AM, Jerry Krinock [EMAIL PROTECTED] wrote:
  That's fine if the classes exist in all the OS versions, but more commonly
 you'll want to use complete classes that are not available in earlier SDK,
 of which there are many, especially in Leopard.  Code instantiating such
 classes must be put in separate bundles that are loaded when the user
 activates a Tiger/Leopard-only feature that requires instantiating a
 Tiger/Leopard-only class.

This is only true if you are subclassing these classes. If you're only
messaging/instantiating them, then you can use NSClassFromString
instead of the raw class name to safely reference them without blowing
up on the OSes that don't have them.

Mike
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Tips to deploy applications to multiple Mac OS X versions

2008-04-09 Thread Lorenzo Bevilacqua

Hi,

I'm trying to build a Cocoa application so that it can run on Mac OS X  
from version 10.3.9 to 10.5.
I have 10.5 installed so the application runs fine on my system and on  
other Leopard systems.
I haven't build a project for multiple platforms yet, so I tried to  
duplicate the main Xcode target and set different deployment target  
settings like


myApp for Leopard   MACOSX_DEPLOYMENT_TARGET set to 10.5
myApp for Tiger MACOSX_DEPLOYMENT_TARGET set to 10.4
myApp for Panther   MACOSX_DEPLOYMENT_TARGET set to 10.3

The SDK I use is the Leopard one.

Till now all Ok, but when I try to compile for example the Tiger  
target I get some errors (mainly about fast enumeration). Thus I have  
some questions:


- It is correct to proceed like I described above?
- Does the Objective-C 2.0 fast enumeration make sense to be used? I  
mean, if I don't use it, will my application perform worse on Leopard?
- Is there a way to differentiate part of code by platform? I remember  
I saw in some files lines like this


#if MACOSX_DEPLOYMENT_TARGET == MAC_OS_X_VERSION_10_4
#endif

is this correct?


Thanks,

Lorenzo Bevilacqua
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Tips to deploy applications to multiple Mac OS X versions

2008-04-09 Thread Michael Vannorsdel
Using Obj-C 2.0 can give a little speed boost over previous versions  
of Mac OS X.  For building for other system versions sometimes you  
need to link to the SDK of that version if you find some symbols are  
missing (depreciated or removed).  If you want to use certain features  
on one platform and not another you can use the #if statements.


#if MACOSX_DEPLOYMENT_TARGET == MAC_OS_X_VERSION_10_4

/* 10.4 code here */

#else

/* code for all others */

#endif


On Apr 9, 2008, at 8:43 AM, Lorenzo Bevilacqua wrote:

I'm trying to build a Cocoa application so that it can run on Mac OS  
X from version 10.3.9 to 10.5.
I have 10.5 installed so the application runs fine on my system and  
on other Leopard systems.
I haven't build a project for multiple platforms yet, so I tried to  
duplicate the main Xcode target and set different deployment target  
settings like


myApp for Leopard   MACOSX_DEPLOYMENT_TARGET set to 10.5
myApp for Tiger MACOSX_DEPLOYMENT_TARGET set to 10.4
myApp for Panther   MACOSX_DEPLOYMENT_TARGET set to 10.3

The SDK I use is the Leopard one.

Till now all Ok, but when I try to compile for example the Tiger  
target I get some errors (mainly about fast enumeration). Thus I  
have some questions:


- It is correct to proceed like I described above?
- Does the Objective-C 2.0 fast enumeration make sense to be used? I  
mean, if I don't use it, will my application perform worse on Leopard?
- Is there a way to differentiate part of code by platform? I  
remember I saw in some files lines like this


#if MACOSX_DEPLOYMENT_TARGET == MAC_OS_X_VERSION_10_4
#endif

is this correct?


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Tips to deploy applications to multiple Mac OS X versions

2008-04-09 Thread PGM


- Does the Objective-C 2.0 fast enumeration make sense to be used? I  
mean, if I don't use it, will my application perform worse on Leopard?


Unless you are doing a huge number of enumerations, the difference is  
speed will not be worth the extra coding hassle. Better check the  
difference using the performance tools, to make sure you are not  
making your code much more complex for a few microseconds of speed gain.


Cheers, Patrick
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]