Every year, we get a new major iOS version to test our apps on. The lucky ones can immediately upgrade to the newest Xcode 12, building against the latest iOS 14 SDK. Some other, larger projects can take a while to get upgraded. Those projects have to be built with Xcode 11 in the meantime. But even though those apps can’t be upgraded yet, they are still expected to work well on the newest iOS. And solving problems and bugs requires debugging.

I recently faced a rare camera bug that only reproduced on the iPhone 11 Pro with iOS 14. The app hasn’t been upgraded yet and was built with Xcode 11. The bug was mission-critical and we couldn’t afford to wait until we upgrade to Xcode 12.

Out of the box, older Xcode versions can’t work with iOS 14 at all. However, with some tricks, I could not only run on iOS 14 but also debug with breakpoints and much more.

Overview

A usual run action in Xcode consists of a few independent steps:

  • Building for the device.
  • Installing the app on the device.
  • Launching the app.
  • Attaching a debugger.

These steps rely on Xcode being able to communicate with the physical device, and the communication interface can change between iOS versions. So debugging an app built with an older version of Xcode requires a few tricks.

Building and Installing a Debug Build to iOS 14

Being able to run against the newest iOS version is a problem that we have to fix every year. Thankfully, the same solution works every time.

An Xcode application bundle contains support files for each iOS version it knows how to work with. Adding support for iOS 14 to Xcode 11 is a matter of copying device support files for iOS 14 into Xcode 11. Commonly, these device support files can be copied from Xcode 12 installed side by side, copied from a coworker’s machine, or downloaded from a popular shared repo.

It’s been already widely discussed, so here’s an article I like on the topic.

Launching the App

With the default setup, a debug app build will automatically try to launch on the selected device after installation. Unfortunately, Xcode 11 doesn’t know how to launch apps on iOS 14, so we get this annoying error alert every time: “Failed to start remote service on device. Please check your connection to your device.”

#mobile #xcode #programming #ios #swift

Debugging on iOS 14 With Xcode 11
29.35 GEEK