DEV Community

Yang Fang
Yang Fang

Posted on

Common Errors Compiling New Flutter Apps on MacOS Catalina

If you followed my previous two guides, you can now compile Flutter apps on MacOS Catalina (despite Flutter restrictions that require you to upgrade your MacOS version). However, you may still run into a few compilation 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 lib/main_development.dart.

Property 'xxx' not found on object of type 'XXX *'

Since XCode 12.4 comes with iOS 14.4 SDK, code written for the newer SDK assuming availability of iOS 15 APIs will fail to compile. The errors look like the following:

Semantic Issue (Xcode): Property 'interruptionLevel' not found on object of type 'UNMutableNotificationContent *'
{Source File Path}:{Line Number}
Enter fullscreen mode Exit fullscreen mode

If you look into the offending source file, you'll likely see usage of library API introduced in iOS 15. The call should already be wrapped with if (@available(iOS 15, tvOS 15, *)), guarding it against runtime errors should the application run on a lower iOS version, but the compilation error still happens if you compile the code with iOS 14 SDK.

Despite my efforts of copying SDK from a new XCode build, I cannot get XCode 12.4 to recognize newer iOS SDK. (If anyone know how, please let me know in the comments)

The workaround is to simply comment out the whole block inside if (@available(iOS 15...)) block. This means regardless of whether iOS 15 is available, we will not execute code for iOS 15. This should be fine for testing purposes. But I reiterate my recommendation to use a virtual machine to build the app properly for your production builds.

Top comments (0)