Flutter Xcode "Undefined name 'main'."

1,063

I solved by using this command to build:

flutter build ios -t lib/splashscreen.dart --release

Where splashscreen.dart is the entrypoint for your app, where void main() => runApp(...) is placed.

Thanks for all comments.

Share:
1,063
Edoardo Cortese
Author by

Edoardo Cortese

Updated on January 03, 2023

Comments

  • Edoardo Cortese
    Edoardo Cortese over 1 year

    When i try to build my flutter project in xcode or via "flutter build ios" command i get this error:

    Xcode screenshot

    This is the flutter doctor output:

    [✓] Flutter (Channel stable, 2.8.1, on macOS 12.2 21D49 darwin-arm, locale it-IT)
        • Flutter version 2.8.1 at /Users/Fenix/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 77d935af4d (7 settimane fa), 2021-12-16 08:37:33 -0800
        • Engine revision 890a5fca2e
        • Dart version 2.15.1
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
        • Android SDK at /Users/Fenix/Library/Android/sdk
        • Platform android-31, build-tools 32.1.0-rc1
        • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • CocoaPods version 1.11.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2021.1)
        • Android Studio at /Applications/Android Studio M1.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
    
    [✓] Android Studio (version 2021.1)
        • Android Studio at /Applications/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
    
    [✓] VS Code (version 1.63.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension can be installed from:
          🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
    
    [✓] Connected device (1 available)
    

    I tried with checking "For install builds only" in Build Phases but i get different error of files not found. I also tried with flutter clean, Clean Build Folder, pod reinstall, etc.

    Thanks a lot.

    • Hardik Mehta
      Hardik Mehta about 2 years
      Have you tried by clearing derived data first ? then flutter clean , flutter pub get and pod install
    • Fahmida
      Fahmida about 2 years
      Do you have any flavor of your app?
    • Edoardo Cortese
      Edoardo Cortese about 2 years
      @Fahmida nope, my app is basically standard
    • Hardik Mehta
      Hardik Mehta about 2 years
      @EdoardoCortese : Please check this stackoverflow.com/questions/59636587/…
  • Edoardo Cortese
    Edoardo Cortese about 2 years
    @HardikMehta yes i tried