Everything You Need to Know About Deployment Targets

Everything You Need to Know About Deployment Targets

You need to understand what a deployment target is if you plan to develop for iOS (and iPadOS), tvOS, macOS, or watchOS. In this episode, you learn everything you need to know about deployment targets, how to set a target's deployment target in Xcode, and when it is appropriate to change the minimum deployment target.

What Is a Deployment Target?

An Xcode project contains one or more targets and each target has a deployment target. If you are building an application that runs on iOS and tvOS, then the Xcode project has at least two targets, one for iOS and one for tvOS. In short, every application that runs on one of Apple's platforms has a deployment target.

A deployment target is nothing more than the minimum version of the operating system the application can run on.

Fire up Xcode and create a new project by choosing the App template from the iOS > Application section.

What is a deployment target?

Because we chose the iOS > Application > App template, Xcode automatically added a target for iOS to the project. In this example, the target is named Books.

Minimum Deployment Target in Xcode 12

Click the Books target and select the General tab at the top. The General tab contains a section with name Deployment Info. The section contains a dropdown menu and three checkboxes, iPhone, iPad, and Mac. Because I am using Xcode 12, the dropdown menu is currently set to iOS 14.3. That is the iOS deployment target or the minimum deployment target for iOS. It means that the application runs on any iOS device with iOS 14.3 or later installed.

Minimum Deployment Target in Xcode 12

The values the dropdown menu lists depend on the version of Xcode you are using. Xcode 12, for example, no longer supports iOS 8. The minimum deployment target Xcode 12 supports is iOS 9.

The Deployment Info section also lists a number of checkboxes. iPhone and iPad are checked while Mac is unchecked. As you may have guessed, the application is compatible with iPhone (and iPod Touch) and iPad, but it won't run on Mac, that is, macOS (previously known as Mac OS X and OS X).

Build Settings

The dropdown menu of the Deployment Info section is nothing more than a convenient way to define a build setting. Select the Build Settings tab at the top and search for deployment target. The Deployment section shows four build settings that relate to the deployment target:

  • iOS Deployment Target
  • macOS Deployment Target
  • tvOS Deployment Target
  • watchOS Deployment Target

You can ignore DriverKit Deployment Target. It is unlikely that you ever need to modify that build setting.

How to Raise the Minimum Deployment Target

There are many reasons for raising the deployment target of an application. Assume you maintain an application that has a deployment target of iOS 12. This means you can't use SwiftUI and Combine. It is technically possible and the compiler can handle it, but it isn't ideal. SwiftUI and Combine were introduced alongside iOS 13, which means you need to raise the deployment target to iOS 13.

Updating the deployment target is as simple as setting the iOS Deployment Target building setting in Xcode. While that isn't difficult, it doesn't end there. What are the consequences of raising the deployment target?

By raising the deployment target, you say goodbye to a portion of your application's userbase. People who use a device that runs an older iOS version will no longer receive updates through the App Store. It is important to check how many users you are leaving behind. This is especially important if you offer a service users rely on or paid for.

When to Raise the Minimum Deployment Target

Before you consider raising the deployment target of a target, you need to decide whether it is appropriate to do so. What are the pros and cons? It is usually obvious what you gain by raising the deployment target, but don't forget that it also has consequences for your application's userbase.

Don't be too aggressive when it comes to raising the deployment target. I once read a story about a developer who lowered the deployment target because a significant number of users complained about no longer being able to receive updates.

Raising the deployment target requires careful planning. This isn't something you do in a bug fix release.

A Word About CocoaPods

I mentioned earlier that Xcode 12 no longer supports iOS 8. This can cause some issues with CocoaPods. It is possible that you see one or more warnings in Xcode that state that the value of IPHONEOS_DEPLOYMENT_TARGET is invalid. This simply means that one or more dependencies (pods) you are using have a minimum deployment target set to 8.0 while Xcode 12 no longer supports that version of iOS. I believe one of the dependencies of the Firebase SDK also suffered from this issue.

There are workarounds for this problem. This GitHub issue suggests setting the IPHONEOS_DEPLOYMENT_TARGET build setting using a post_install hook in your project's Podfile.