Andy Hin
Andy Hin

Reputation: 31953

What is the best way to make sure I am not using any unavailable API's on OSX?

I am writing an OSX app in Xcode 6 but want my application to have support for OSX 10.7 and up. Unfortunately Xcode 6 only includes SDK for 10.10 and 10.9.

What is the best way to make sure I am not using any unavailable API's that would crash on 10.7 and 10.8?

Upvotes: 4

Views: 132

Answers (1)

Joshua Nozzi
Joshua Nozzi

Reputation: 61228

For the moment, there's no easy way to do this, since as you said, 10.9 is the farthest back you can specify. Until Xcode 7 is released, which I believe will only help with more recent SDKs anyway, you have few choices, none at all convenient:

  1. Keep a cheap Mac around loaded with 10.7 and Xcode 4 or 5 (whichever comes with the 10.7 SDK) and try building your project there (so the compiler will automatically catch all unknown symbols). You can even get a capable Mini and keep it "headless" (no monitor/keyboard/pointing device) and use remote desktop to drive it. You can use a hosted repo or a shared drive to access your latest code for testing alongside your primary working Mac. This truly is the best catch-all, since you should have a way to reproduce problems that may occur only on the older OS version anyway.

  2. Maintain a large enough partition on your existing Mac's internal (or an external) hard drive with 10.7/older Xcode into which you can periodically boot to do the same thing. This is less convenient than 1 for what I hope are obvious reasons, but workable if buying another Mac isn't a viable option.

  3. The absolute worst and most error-prone way would be to go through all your code manually and look up their availability. This obviously sucks but you should already know your own app's design and whether or not you're "alright so far", so with this in mind, you can apply this basic check to any new code changes / planned features as you go.

  4. [Edit] See JWWalker's comment below.

For an application I wrote and maintain for Uncle Sam (the current version of which must support back to 10.6), I use a mixture of 1 and 3. That is, I keep a headless Mini loaded with 10.6 and Xcode 3 but develop on the latest hardware / software. I vet any bug fixes or minor enhancements I have to make as reasonably as I can by stopping and thinking of my design / changes and verifying with the documentation that the symbol(s) involved are available. I've grown with the platform so I'm pretty good about avoiding newer API anyway but I occasionally get caught out when I go to build the internal beta for distribution (which must be done on the headless Mini so it can catch any final problems).

Another gotcha with supporting old stuff while using new stuff, however, is when editing NIBs/XIBs. Newer IB versions tend to auto-upgrade the format to be "helpful" (or they force it) if you use the newer tools, which mean they can't be read even to be compiled by ibtool. Fortunately these days, I'm just issuing bug fixes to code for the production version of this app since the focus of late is on the next major version, which mercifully may target 10.9 and up.

Again I'll say "this obviously sucks."

Upvotes: 4

Related Questions