SDK 3.0 / 2.x Targets

SDKs, Targets, and iPhone OS 3.0

Note: This was previously posted on our logged-in developer site, and has quickly been pasted here because of public interest. There are a number of references to Pinch Analytics-specifics stuff because this is documentation for Pinch Analytics users; that said, it has lots of useful background information that should clear up some confusion for many iPhone developers. YMMV. If this is your first introduction to Pinch Analytics, check out our main website www.pinchmedia.com to see what we do.

TL;DR: set your Base SDK to iPhone OS 3.0 for all configurations, and set the iPhone OS Deployment Target to the OS you'd like to deploy on.

A number of developers have had trouble building their projects in Xcode after switching to the latest release of Pinch Analytics (libPMAnalytics-r64.a). The error references ___save_vfp_d8_d15_regs and ___restore_vfp_d8_d15_regs, and only happens when building for iPhone OS 2.x.

Luckily, the solution is very simple, but the amount of support requests we've gotten about this issue tells us that Apple's documentation isn't clear enough. We'll go over the fundamentals of the issue, and then show you how to fix it. Feel free to skip the Background section if you just want to know how to fix things.

Background

The confusion (and build errors) come from the distinction of SDKs and deployment targets. Hopefully, this explanation will clear things up!

SDKs

In iPhone-land (and in most other computation-lands — but we're iPhone developers here), an SDK is a release of a slew of APIs in the form of frameworks, dynamic libraries, and static libraries, as well as a compiler/linker/code signer/etc. (the "toolchain"). Each release of the iPhone SDK builds on the previous one, typically by adding new frameworks and libraries or just adding new functionality to pre-existing frameworks.

Before the 3.0 SDK release, updates worked just like that: developers could opt to use new features of, for instance, the 2.2 SDK. Then, their applications would only run on devices running iPhone OS 2.2 or greater. Most developers would choose which OS they wanted to deploy on by picking it from the drop-down menu in the Xcode toolbar: "iPhone Device 2.1", for instance. Easy!

Something changed in 3.0, though. The compiler has some new features! (One might surmise that the release of the iPhone 3G S, with its fancy new processor and ARMv7 instruction set, has a lot to do with this.) Another Big Change indicator is that we were previously dealing with dot releases (2.0, 2.1, 2.2), and now we've jumped to 3.0.

Targets

So there are SDKs, and then there are targets. Targets are a fairly simple concept: since a new version of the SDK builds on its predecessor, new functionality can be disabled to match the feature set of an older SDK. Then, an app can be compiled with the newer SDK, but function on an older OS. For instance, if your application doesn't require Core Data, Store Kit, or other new features of 3.0, you can choose to target iPhone OS 2.2.

Why wouldn't I just target the latest version? Normal people are different from developers. They're lazy! Their phones work; why sync? Why update? Apple does a good job of pushing people to update, but there are still plenty of devices out there running older versions of the iPhone OS. If your app doesn't use the newer APIs, but you target the latest version anyway, you'll prevent users on older OSes from installing your app. You'll lose sales! That's Bad!

Rule of thumb: target the lowest OS version that your app can compile on.

What changed with r64?

Pinch Analytics r64 is our first official release built with the 3.0 iPhone SDK. Since we want to support as many configurations as possible, we target iPhone OS 2.0 — the first release of the SDK. Our library is compatible with any iPhone application targeting any version of the iPhone OS. Sure, this means we're stuck with writing ugly SQLite code in C instead of using the beautiful new Core Data framework in 3.0, but it means that any app can use our library... but now with with one caveat:

To use r64, you must compile your app using the 3.0 SDK, regardless of which version of the iPhone OS you choose to target.

Why? Because the compiler has changed in 3.0, and the binaries it produces are not compatible with older toolchains. Since we at Pinch Media like to write good software, we subscribe to Apple's best practices and recommendations, and they want everybody to compile with the 3.0 SDK. So we do! You should use it too. At some point, when Apple drops support for the older SDKs, you'll have to anyway.

So, how do I fix the build errors?

Enough background. Let's take it step by step:

  1. In Xcode, Get Info on your project, which is the top item in the "Groups & Files" pane on the left side.
  2. Choose the Build tab.
  3. Choose "All Configurations" in the Configuration drop-down.
  4. Choose "All Settings" in the Show drop-down.
  5. Find the Base SDK setting, and set it to iPhone Device 3.0.
  6. Find the iPhone OS Deployment Target setting.
  7. This is where you must make a choice. You'll want to select the lowest version of the iPhone OS that will allow your project to build, so your app will be compatible with as many devices as possible. You can read Apple's documentation for the APIs you're using to determine which version will work for you. Or, you might want to start with iPhone OS 2.0; clean and build; and if it fails go for the next version. There are only 5 choices (at time of writing), so guess-and-check isn't a terrible choice.
  8. Avoid the temptation to change the Active SDK version in the drop-down menu on the left side of the main Xcode toolbar — leave it on 3.0! Feel free, however, to use this menu to switch between the Device and Simulator.

Again, we must stress that you should target the lowest version of the iPhone OS that your app can build on, so your app is compatible with as many devices as possible. More compatibility = more sales!

At this point, you're probably wondering how many users are still running old versions of the iPhone OS. We've recently started sending a weekly newsletter with brief updates about Pinch, a blurb on mobile application news, and (drumroll) useful stats for developers. We've been including a "Stats by OS Version (weekly)" chart in each newsletter — and this is probably the only place you'll be able to get this information. You can opt in to the newsletter in preferences, and we promise we won't spam you and that the newsletter is worth it.

One more note for non-Pinch-account-having visitors: we'll have a public opt-in to that newsletter up on our main website sometime very soon. In the meantime, you can just sign up for an account; it doesn't hurt, we promise :]