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
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
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
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
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.
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.
Other Common Errors
pod not found
Sometimes you will encounter a build error in XCode complaining about pods. You have to go to the
ios folder in your project and run
pod install in the terminal.
Error when reading 'lib/main.dart'
If your flutter entry point is not main.dart (such as using project templates that uses different flavor names), you will need to point to the entry point file in "Build Settings". Under "Build Settings" there is "FLUTTER_TARGET" which should point to your entry point file such as
Top comments (0)