19

after reading the apple SDK guide https://developer.apple.com/library/mac/#documentation/developertools/conceptual/cross_development/Overview/overview.html

I'm still confused of how to make the mac app backward compatible & how to test them properly

I have an app, I run it and tested it on Mountain Lion 10.8 without any problem, however I want to make this app backward compatible so that other users can run it on a mac 10.6 - 10.7 machine.

  1. I have an apple developer id and I can download the old versions of 10.7 and 10.6, but the problem is, I have a 2011 macbook air which is currently running 10.8, and that's the only apple machine that I have. Can I test the 10.7 and 10.6 by using vmware or parallels?

  2. in my project settings, I set the target deployment to 10.6 (as I want 10.6 users to run my app), but should I set my SDK to 10.8 or 10.7? if I set the SDK to 10.8 but having the target deployment set to 10.6, if I fix all the xcode warnings will it run successfully on 10.6??

  3. from the SDK drop down, I can only set to 10.8 or 10.7, but 10.6 is missing, how do I fix that?

thanks in advance

Josh
  • 692
  • 2
  • 9
  • 38

4 Answers4

45

I develop on a 10.8 box and support back to 10.5. Just a couple of months ago we dropped 10.4 PPC support, and I'm still cleaning out some of the 10.2-specific code. This may get a little rant-y, but I've been doing old versions for a long time. I have some opinions on the matter.

  • No matter what Apple says in their docs, if you want to support 10.6, then build with the 10.6 SDK. Do not rely on distribution target.
    • I have had this discussion with the Xcode engineers, and while they hold to Apple's party line that you should always build with the latest SDK, they also acknowledge that it's generally insane to do so. If you build against the 10.8 SDK and mark your deployment target at 10.6, you will get no warnings for using methods that do not exist on 10.6. The only way you will discover that you've used a nonexistent method is that it might give you strange bugs when run on 10.6. That's insane.
    • Remember, OS X doesn't crash when you send an unknown selector. It just aborts the current runloop. So the bugs are even harder to track down then on iOS, where it crashes the app.
    • Sure, you can do weak linking. Talk about dangerous.... Yes, there are a few times this is useful, but the compiler gives you no warning if you don't do it correctly. If I'm going to do weak linking like this, I go the other way, linking against the old SDK and copying the new function's prototype into my implementation. That way I have documentation of every function I think I'm going to weak-link.
  • Download the old SDKs and symlink them into your Xcode distribution.
    • Guard them jealously. Apple will try to delete them every time you upgrade Xcode. Make your own copies and stick them in /SDKs or somewhere else away from Xcode. I provide a script called fix-xcode to manage the symlinks automatically. Am I bitter at Apple for their relentless insistance on deleting my old SDKs? Yes, I am.
  • You can run 10.6 Server in a VM legally. You can run 10.7+ Desktop in a VM legally. These are good ways to test your code.
    • Or you can do what I do and have a small pile of old MacBooks each with two or three partitions on them that you reboot all the time.
    • Now that 10.7 comes from App Store, it's a little harder to make VMs. My strong recommendation is to snapshot your image immediately after install, and make a clean backup copy of it. You'll want to be able to clone that image from time to time when you need to get back to a "raw" machine.
    • Get in the habit of squirreling away SDKs as they come out. 10.8 will be old some day. You might as well make a copy now while it's easy.
  • Whether you support individual dot-releases or not, it can be very helpful to keep around the upgrade packages for individual dot releases. When you encounter customers running non-current releases, it's nice to be able to check whether an "unreproducible" bug in fact is easily reproducible on their specific version. Whether this is worth it or not depends heavily on your product and customers. It was a life-saver for me when 10.4.11 made major changes to WebKit during a dot release...
  • Invest in a small NAS or a big external USB drive (though I've had trouble with those failing when used extensively, so I prefer a RAID). You'll need the space. You want to hold onto lots of VMs and lots of SDKs and sometimes even old versions of Xcode.
Rob Napier
  • 286,113
  • 34
  • 456
  • 610
  • 2
    wow, after reading all those comments and reread the apple documentation, I really thought that if I set the deployment target to 10.6 and set the SDK to the latest version, xcode will warn me if I use any unsupported methods. so really, thank you so much for your help on this!! – Josh Feb 26 '13 at 23:25
  • @Rob Napier I have a problem though, I found the 10.6 SDK and I copied to my /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/ I start testing the 10.6 sdk by creating a dummy project, set the target deployment to 10.6 and sdk to 10.6 but I got bunch of errors: http://i56.tinypic.com/hsu92f.png – Josh Feb 27 '13 at 15:50
  • You cannot compile for ARC with the 10.6 SDK. You must build with the 10.7 SDK and use a 10.6 distribution target. The point of building with an older SDK is that you're using *exactly* what was available with that SDK (which reduces the likelihood of bugs). In asking for ARC, you're actually asking for 10.7 things than happen to run on 10.6. If you want to be *certain* it will work on 10.6, you can't use 10.7 features like ARC. In your place, I would (and do) set my SDK to 10.7 and live with the higher risk of bugs on 10.6. (But I don't use 10.8. 10.7 is the oldest that has the feature.) – Rob Napier Feb 27 '13 at 17:30
  • We use an app called DeployMate to check our code for 10.8 compatibility, works well, but I find it unbelievable that Apple forces us to resort to such workarounds. – Andreas Zollmann Mar 26 '15 at 21:48
  • @Rob Napier: Any response from Apple to your ticket after now 3 years?? – Andreas Zollmann Mar 26 '15 at 21:49
2

Adding to Rob Napier's great in-depth answer:

To use an old SDK, put the SDK (or a symlink) to it here:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs

With XCode 7.3 or later, you need you to open this file and change "MinimumSDKVersion" (otherwise XCode will refuse to use the old SDK):

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Info.plist
Community
  • 1
  • 1
Jakob
  • 119
  • 1
  • 6
1
  1. You can install multiple versions of Mac OS on a single machine, booting between each.
  2. The SDK should be the latest (10.8).
  3. See 2.

One alternative to 1 that I've considered (I am in the same boat) is to create a Snow Leopard Hackintosh using an old PC and just installing Lion and Mountain Lion on my MBP.

trojanfoe
  • 120,358
  • 21
  • 212
  • 242
  • thanks, my macbook air used to run 10.7 so installing 10.7 on it should be no problem, but how am I going to install 10.6? I was told that the hardware cannot be newer than the software (10.6) – Josh Feb 26 '13 at 14:25
  • Yeah it looks like the 2011 models cannot run 10.6. You're gonna have to try the Hackintosh approach or buy a Mac Mini or something. I have a friend with Snow Leopard to cover that base for me... – trojanfoe Feb 26 '13 at 14:27
  • guess I will have to reinstall 10.6 on my dell inspiron 530, thanks dude – Josh Feb 26 '13 at 14:35
0

You need to do these settings :

1.Set the Base SDK to Current version of Mac (ex. 10.7)

2.Set the Deployment SDK to older version (ex.1.4)

Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140