DEV Community

Yang Fang
Yang Fang

Posted on • Updated on

Deploying Flutter to iOS 15 on MacOS Catalina

Continuing from the last post, where I discussed how to work around Flutter's XCode version requirement, in this post, I will discuss how to deploy a test iOS App on a real iOS device (a.k.a. iPhone).

Similar to Flutter, XCode also has compatibility requirements between XCode versions and deployable iOS versions. With Catalina, the latest supported XCode version is 12.4, and the latest supported iOS version is iOS 14.4. This poses a problem, because almost all modern iPhones currently run a later version of iOS. Even an "ancient" iPhone 6s from 2015 runs iOS 15.7 today. Since Apple does not sign old iOS versions, users are unable to downgrade to previous iOS versions (outside of jailbreaking). Thus, current iPhone devices can't be used for testing.

Over the past few years, various people on the Internet have figured out workarounds to specific issues arising from these restrictions. I have compiled a step by step guide below and will reference these posts when I go over what changes needed to be made to a default XCode 12.4 installation on macOS Catalina with Flutter 3.3.10 in order to deploy to an iPhone 6S running iOS 15.7.

As a prerequisite, you'll want to make sure Flutter 3.3.10 builds your project and deploys to the iOS simulator (simulating iOS 14.4). This should be the case if you followed my previous post.

Now we will connect the iPhone 6S to the Mac running macOS Catalina. You may be prompted to install software components to sync this iOS version (this doesn't have anything to do with XCode, just normal iTune/Finder sync), which I recommend installing. After that, you should see your iPhone show up in Finder.

Download Device Support Files

[Reference]

Since we want to deploy to iOS 15.7, we will need the Device Support files for this iOS version. Head to https://github.com/iGhibli/iOS-DeviceSupport and download DeviceSupport/15.7(FromXcode_14.1_Release_Candidate_xip).zip, unzip this file in Finder, then move the folder 15.7 to /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport.

If you're deploying to iOS 16, then download Device Support for iOS 16.1, and rename the folder to the corresponding iOS version on your device.

Update Signing Config in XCode

In order to deploy to a real device, the app needs to be signed using an Apple ID (a.k.a. iCloud login), which is free. App signing is normally done by XCode.

We will then open the Flutter iOS project in XCode. Remember this is the ios/Runner.xcworkspace file and not the ios/Runner.xcodeproj file.

In the project navigator, click on the Runner project. This opens Runner.xcodeproj properties. On the tab bar (where it shows "Info", "Build Settings", etc), make sure that the Runner target is selected (not Runner project). Go to "Signing & Capabilities". Here you will see that Team is set to none. Select the dropdown and add an account. A preference window will open. Sign in to your Apple ID in the preference window.

After that, close out of the preference window and select the signed in account in Team. If you see a message that says no matching device is available, click the device name from the XCode title bar "Runner > (device name)" drop down menu (this is located at the top of the window next to the ▷ and □ buttons). Then, select iPhone 6s in the dropdown. This should register the iPhone with XCode and get a provisioning profile for 7 days.

Update More Signing Config in XCode

[Reference]

We are not quite done as there is one more hurdle. Apple changed the signature format, and requires an additional commandline change. Otherwise the deployment will fail with a signature error.

In Runner.xcodeproj properties, make sure that the Runner target is selected. Go to "Build Settings" tab. Select the "All" sub-tab. Search for "Other Code Signing Flags". Add --generate-entitlement-der in the field.

Now you should finally be able to deploy to iPhone 6S on XCode 12.4 on macOS Catalina.

Top comments (0)