Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mac SDK: using latest SDK but ensuring backwards compatibility with earlier deployment target

As always when Apple updates OS X, the latest XCode 4.4 dumps the older (10.6) SDK and I find myself needing to use the 10.7 SDK (or 10.8 I suppose) and setting my deployment target to 10.6 to maintain compatibility.

I prefer linking to the older SDK because I know that I cannot by mistake introduce calls to APIs that do not yet exist. Something that I found myself doing regularly when I last tried the inverse approach.

What I find myself doing is that I use the code completion feature in XCode to choose the "right" call for a simple class like NSWorkspace, then everything works fine during development, I forget about it and when I release a new version: Kaboum! The whole application explodes on earlier OS X releases at run-time; often in those hard-to-reach places :-)

Or at least this was the situation for me a few years back.

Surely, by now there's a way to either:

  • making sure you don't introduce API calls that are not yet available in your deployment target even if though they are defined in the SDK

  • detecting such calls during build or static analysis time

I'm sure I've missed something, somewhere along the line.. Please enlighten me!

Best regards,

Frank

like image 348
Frank R. Avatar asked Jul 27 '12 08:07

Frank R.


People also ask

Is SwiftUI backward compatible?

No backward compatibility First, because it lacks backward compatibility. SwiftUI is supported only on iOS 13 and higher. Even if this version of mobile OS is used by most iPhones & iPads, it still isn't by all of them. There are still many iOS-12-and-lower devices.

Does Xcode 13 support iOS 15. 5?

Xcode 13 includes SDKs for iOS 15, iPadOS 15, tvOS 15, watchOS 8, and macOS Big Sur 11.3. The Xcode 13 release supports on-device debugging for iOS 9 and later, tvOS 9 and later, and watchOS 2 and later. Xcode 13 requires a Mac running macOS 11.3 or later.

What is Macosx SDK?

A macOS SDK is an on-disk directory that contains header files and meta information for macOS APIs. Apple distributes SDKs as part of the Xcode app bundle. Each Xcode version comes with one macOS SDK, the SDK for the most recent released version of macOS at the time of the Xcode release.


2 Answers

Surely, by now there's a way to either:

  • making sure you don't introduce API calls that are not yet available in your deployment target even if though they are defined in the SDK

  • detecting such calls during build or static analysis time

No there is not. Yes, you should open a radar (bugreport.apple.com) against it. If you like, you can dupe mine: rdar://11985733

Yes, the only viable solution, despite Apple's recommendation, is to copy the old SDKs and link against them.

I spent quite some time talking with the Xcode team about exactly this issue at WWDC 2012. They agreed that it's broken. There is not currently a plan to fix it. Escalating radar's is how we influence Apple on these things.

like image 187
Rob Napier Avatar answered Oct 20 '22 02:10

Rob Napier


I'm generally copy SDK from older versions to the newer one so that compiler will blain me if i use something not supported.

Also you can simply look at Quick Help when calling some methods that you are not sure about, like in screenshot you can see that launchApplicationAtURL method is only available from 10.6

enter image description here

like image 28
Shebuka Avatar answered Oct 20 '22 02:10

Shebuka