Cocoa/Xcode - OSX retrocompatibility - objective-c

I wrote a Cocoa app on my Mac which is 10.6.6. I sent it to a friend who has 10.5.7 and they got this error:
Cannot open this app with this version of OSX
How can I make my app retrocompatible with minimum 10.4 Tiger ?

Set the Mac OS X Deployment Target in your Target build settings to OS X 10.4. And make sure to not use any 10.5 or 10.6-only APIs without checking for their availability first.

For 10.5 you can set the deployment target to 10.5 and make sure you only use APIs available in 10.5 (you should get warnings for 10.6 only APIs).
For 10.4, you'll probably need to install the 10.4 SDK from the Xcode install and use that SDK. If you have any properties declared, you'll also have to change them to getter/setter pairs and manually implement the getter/setters for synthesized properties.
If at all possible, you should avoid having to support 10.4 because the runtime predates Objective-C 2.0.

Related

How to set compile time flags to include specific framework at runtime

Our application is supported from Mac OS X 10.5 and we are including a feature which has support from Mac OS X 10.7 and above.
How can I make a common application where in the customers on 10.5 and 10.6 doesn't get that feature and 10.7 and above get that feature.
What should be the conditional flag I should use in the code so that framework shouldn't be loaded once the application run on 10.6 and below?

Will Mac application developed in latest XCode work in old OS-X?

I have MacOS-X - 10.7 and Xcode - 4.6.2 and made a Mac application. The client side machine is also MacOS-X - 10.7. But in my mac application there was a small error with NSNumberFormatter which when I was changing, Xcode was crashing. So I edited the code in latest Xcode and OSX. And then I made the binary of it and run in MacOS-x - 10.7, its working fine. But the source code is no more opening in Xcode - 4.6.2. Its asking for the latest version of Xcode. My question is will the binary will work fine in older version of OS-X even if it is developed in latest Xcode?
The version of OS X which your application will run on is dictated by the OS X Deployment Target in the project settings. If that is set to support 10.7, then it doesn't matter which version of OS X you built it on: the built application will work on 10.7 and later.
This setting will also set the minimum allowed OS in the Info.plist, so people trying to run the build on earlier OSes will see an alert instead of the app just crashing.
More information on setting the deployment target and building for different OS versions with SDKs is available in the Apple documentation:
https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/cross_development/Configuring/configuring.html

Backward compatibility for OSX Apps

OK, so here's my situation :
I've got Xcode 5.1.1 on a 10.9 (Mavericks) machine
I want to build my app so that it runs on 10.6 and later
SDKs installed : 10.6, 10.8, 10.9
What do I have to do to make sure it'll show up as "10.6 and later" compatible in the app store?
I managed to get it to compile fine with Base SDK set to either 10.8 or 10.9, and Deployment Target set to 10.6. Will that suffice?
P.S. I've tried compiling with Base SDK set to 10.6, as well, but there are so many errors to be fixed, that it'd be better if I could avoid it.
So any ideas?
Yes; using 10.9 SDK with the deployment target of 10.6 will work fine.
You may find you have conditional code-paths which must be determined at runtime, perhaps based on respondsToSelector, which will require some #pragmas in order to compile successfully.
The Deployment Target defines the minimum OS version that your app requires at run time.
The Base SDK defines the level of API features that are available at compile time.
Therefore you can use 10.9 as Base SDK when building apps that can run on 10.6 and upwards.
You just have to make sure to avoid code paths that use 10.7/10.8/10.9 APIs when your app runs on a 10.6 machine.
As trojanfoe already pointed out, you can use respondsToSelector: to check if a certain class/method is available.
Another way is to use NSAppKitVersionNumber:
if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_8)
The NSAppKitVersionNumber constants for the latest SDK can be found in the AppKit Release Notes.
Further details can be found in Apple's SDK Compatibility Guide.

Compile program for older versions of Mac

I have an objective c script that takes a Mac's system information and outputs it as an XML with specific tags. It works on Mountain Lion and Lion, but doesn't work with any versions besides those. Up to 10.5 would be ideal. When I run it on 10.6.8, I get a Bad CPU error. Any suggestions?
Xcode 4.5.1 comes with OS X 10.7 and 10.8 SDKs. To compile programs that run on earlier OS X versions, you have to set the "OS X Deployment Target" in the Info tab of the program settings.
"Automatic Reference Counting" is only supported on OS X 10.6 and later (see Objective-C Feature Availability Index). If you want to deploy to 10.5, you have to compile without ARC. So either
you create a new project and uncheck the "Use Automatic Reference Counting", or
you set "Objective-C Automatic Reference Counting" to "No" in the Build Settings.
To build executables that run on 32-bit processors, you have to set "Architectures" to "32-bit Intel" in the Build settings. By default, Xcode 4.5.1 will compile for the architecture of the compile machine (which most probably is 64-bit). But in this case you can not use ARC, because ARC requires the so-called "modern runtime", which is available only on 64-bit systems.

glib for mac os 10.6 snow leopard

am developing one dictionary for mac os 10.6. Am not able to locate glib.h. can i get this as a library or framework. am confused very much. please give me your valuable solution.
Note: i want to use GSList from glib
Install it using MacPorts or download the source code and install manually. Or if you're developing a cocoa aplication I'm sure the framework has it's own list structures, it would be better to use the native ones.