Friday, January 12, 2024

Build environment to run Flutter apps on iOS

This is another personal memo. There have been quite a few glitches to overcome, to run Flutter apps on my newly bought M2 mac. I want to write about them, before closing the tabs of the pages explaining the solutions.

CocoaPods

What is CocoaPods?

CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects. (https://cocoapods.org/)

When you try to run your Flutter app for the first time on an iOS device (one of the simulators, most probably), the system complains that CocoaPods is missing.

OK. No problem. Let me install, following the instruction found on the above project site. Then, the first glitch. The instruction won't work. There seem compatibility issues for Cocoapods and silicon chip based M1 and M2 based macs, which prevents it from directly installing Cocoapods on these machines.

The solution is found at this page. You basically first install a tool called Homebrew, and then let it install CocoaPods for you.

Unable to boot the Simulator

It has suddenly become that I am not able to boot any iOS simulator.

You may be lucky that this does not happen on your system. But it did to me (I suspect that this is due a Xcode update, but not sure), and it took sometime to remove the problem. So it should be worth to write here what I did for future reference.

So this is what you want to do, you go to "About this Mac" > "More info..." >Developer (info icon) > Select anything that has "xcode" and "cache" in it > Click "Delete". Close all this and relaunch simulator.

error:iOS 17.2 is not installed. To use with Xcode, first download and install the platform

Now that the iPhone 15 on iOS 17.0 is running. I tried to deploy the app onto it and got this error.

I first did not understand why I need to install the iOS 17.2 SDK. I have ones for 17.0 and 17.0.1. The simulator is on 17.0. Why is 17.2 required??

Now I understand as follows. At the time of this writing, I am on Xcode 15.2 on macOS Ventura 13.6.1. https://developer.apple.com/support/xcode/ reads as below, that Xcode 15.2 requires the iOS SDK 17.2.



I installed the SDK as instructed by the error message. And finally, I can now run my app on the simulator.