Flutter iOS app for MacOS (Apple Silicon)
Up till now I had never bothered to look into MacOS compatibility. Scratch that, I did years ago when Flutter first became compatible with MacOS. However at the time, Google Sign In were not, so I could not have run any of my apps on MacOS anyway. This week I finally got enough time to dive into it.
Automatic support of iOS on MacOS (Apple Silicon)
After I installed TestFlight on my Mac, I was surprised to see that half of my iOS apps could already be installed and run natively on it. How? And why wasn't the one I wanted to run available to run on Mac?
package compatibility
At first I thought it was because it relied on packages that were not marked as being compatible with macos. For exemple https://pub.dev/packages/geocoding.

But even after migrating away from this package, and making sure all dependencies support MacOS, my app was not available in TestFlight on MacOS.
Could it be that the iOS binary is not compatible with MacOS because of some package I missed? It would be really nice to be able to know without having to blindly compile, send it to TestFlight and cross fingers.
Checking Flutter-side compatibility
I asked Google and apparently there are tools to do it.

After adding pubspec_checker
to my dev_dependencies, I ran dart run pubspec_checker ios macos
and got this matrix:

So my iOS app should totally be compatible to run on MacOS. And yet it still won't show up as being available to run in TestFlight! Could it be some XCode setting?
XCode
Even after comparing two projects, one that was compatible with MacOS and one that was not, according to TestFlight, I could not see any notable difference in settings.
Enabling compatibility in TestFlight
After reading the official documentation on the subject, my app does not seem to use any feature that is specific only to iOS and wouldn't work on MacOS.

My app does use the device's GPS location. But apparently, even though Macs do not have a GPS, the API, Core Location, works even without a GPS.
The absence of specific hardware on a Mac doesn’t always require you to opt out. You can disable parts of your app that require device-specific hardware, allowing the user to use the rest of your app. Some technologies might also be capable of operating without specific hardware. For example, Core Location doesn’t require GPS to return location data.
Apparently, one can test an iOS app on Mac Silicon without running it in the Simulator. Neat!
Xcode supports debugging, testing, and profiling your iOS app natively on a Mac with Apple silicon. When you open your iOS project in Xcode 12 or later, you have the option to build your app and run it directly in macOS. This option doesn’t run your app in a Simulator; it runs it as an iOS App on Mac. You can then test whether your app’s features work as expected.
And finally, this is the section that was most relevant to my app: https://developer.apple.com/documentation/apple-silicon/running-your-ios-apps-in-macos#Choose-whether-to-include-your-iOS-app-in-the-Mac-App-Store
the App Store automatically makes compatible iOS apps available to users of a Mac with Apple silicon. However, if you’re planning to ship a macOS version of your app, or if your app doesn’t make sense for a Mac, you can change your app’s availability in App Store Connect.
I went to App Store Connect and compared the TestFlight settings of the app that worked and the one that didn't on MacOS and sure enough, the setting for "Test iPhone and iPad Apps on Apple Silicon Macs" was different! After clicking Enable, the app was immediately made available on MacOS in TestFlight!

Platform-dependent features
Now that I was able to run the iOS app natively on MacOS, I noticed a few problems. On a regular iOS app, I want an App Title to show what app it is. But on MacOS, the window title already states what the app is, so I don't need an App Title. I also noticed the text was slightly too small on MacOS. I wanted to scale the text.
So I tried to platform-dependent logic using Platform.isMacOS
. Unfortunately it did not seem to work. Another Google search reveals that when running an iOS app on MacOS, Platform.isMacOS
is false
and Platform.isIOS
is true
.

However there are packages that help you detect if it is an iOS app running on MacOS.

That's cool, but after testing my app some more, I am more aware of some limitations which make me want to actually implement real MacOS support.
Limitations
It would take more than just a few cosmetics to make my app comfortable to use on MacOS.
Image picker
My app can send images and the image picker I used only lets you pick among pictures in the Photos Library. On iOS it works as intended. On MacOS, I'd like to be able to drop any image file onto it and upload that. I'd also like a proper File Picker.