Home > database >  Flutter iOS build fails with multiple errors in ios/Runner/AppDelegate.swift
Flutter iOS build fails with multiple errors in ios/Runner/AppDelegate.swift

Time:08-27

I built a Flutter 2.10.5 app that works well on Android. I am now trying to build it for IOS with codemagic devices but I get some errors:

/Users/builder/clone/ios/Runner/AppDelegate.swift:11:9: error: expected expression in list of expressions
        if (@available(iOS 10.0, *)) {
            ^
    /Users/builder/clone/ios/Runner/AppDelegate.swift:12:31: error: expected ',' separator
        [UNUserNotificationCenter currentNotificationCenter].delegate = (id<UNUserNotificationCenterDelegate>) self;
                                  ^
                                 ,
    /Users/builder/clone/ios/Runner/AppDelegate.swift:11:8: error: cannot convert value of type '()' to expected condition type 'Bool'
        if (@available(iOS 10.0, *)) {
           ^~~~~~~~~~~~~~~~~~~~~~~~~
    /Users/builder/clone/ios/Runner/AppDelegate.swift:12:31: error: cannot find 'currentNotificationCenter' in scope
        [UNUserNotificationCenter currentNotificationCenter].delegate = (id<UNUserNotificationCenterDelegate>) self;
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~

I didn't find a lot about those issues. Is it a problem with the swift code generated by Flutter ? In which case there is little I can do to solve it.

CodePudding user response:

first you can try to build using Xcode 12.5 version to check if the error caused by old Flutter version. Currently Codemagic uses Xcode 13.4 by default so you can change it in App Settings > Build > Xcode version.

Also you can try to recreate ios folder

cd project
rm -rf ios
flutter create .
  • Related