skip to Main Content

I recently got a new M1 Mac and updated both the flutter version (to Flutter v2.5.1) and Xcode version (to Xcode 13.0) (Not a wise decision). I tried running on the iOS simulator and got stuck at the error ‘Flutter/Flutter.h’ file not found’. I have updated all my dependencies to the latest version. I tried deleting ‘iOS’ folder and doing flutter create, but this brought me back to the same error again. I tried all of the recommended solutions from previous posts on the same issue to no avail (ie. removing Flutter.podspec, removing pod file.lock). I also didn’t switch from master branch to stable (I was always in stable). I have tried almost all the solutions, but none of them have fixed it for me. Thank you for the help.

(Side Note: I tried running on Android emulator and everything works fine except for GoogleSignIn)

ravipenikelapati@Ravis-MBP Creww-App % flutter doctor -v
[✓] Flutter (Channel stable, 2.5.1, on macOS 11.6 20G165 darwin-arm, locale en-US)
    • Flutter version 2.5.1 at /Users/ravipenikelapati/FlutterDev/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ffb2ecea52 (11 days ago), 2021-09-17 15:26:33 -0400
    • Engine revision b3af521a05
    • Dart version 2.14.2

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/ravipenikelapati/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /Users/ravipenikelapati/Downloads/Android
      Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 13.0, Build version 13A233
    • CocoaPods version 1.11.2

[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google
    Chrome.app/Contents/MacOS/Google Chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Android Studio (version 2020.3)
    • Android Studio at /Users/ravipenikelapati/Downloads/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.10+0-b96-7249189)

[✓] VS Code (version 1.60.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.26.0

[✓] Connected device (1 available)
    • iPhone 13 (mobile) • 21F1617B-4715-4EC9-B15D-2DD55519E7D3 • ios •
      com.apple.CoreSimulator.SimRuntime.iOS-15-0 (simulator)

! Doctor found issues in 1 category.

Flutter error output:

Launching lib/main.dart on iPhone 13 in debug mode...
lib/main.dart:1
Xcode build done.                                            8.2s
Failed to build iOS app
Error output from Xcode build:
↳
    --- xcodebuild: WARNING: Using the first of multiple matching destinations:
    { platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Any iOS Simulator Device }
    { platform:iOS Simulator, id:92375C2D-F6DE-4B7F-869B-FD16EE37BC0A, OS:15.0, name:iPad (9th generation) }
    { platform:iOS Simulator, id:64D26107-BE18-4ED7-9238-4BF3DADA2301, OS:15.0, name:iPad Air (4th generation) }
    { platform:iOS Simulator, id:BA3609E7-7F27-4440-879C-3DC65D18E838, OS:15.0, name:iPad Pro (9.7-inch) }
    { platform:iOS Simulator, id:FE7AADF2-E380-4139-B1AF-004029F33C29, OS:15.0, name:iPad Pro (11-inch) (3rd generation) }
    { platform:iOS Simulator, id:8FA3DEC3-3F12-47E3-8490-A4E4786A8C77, OS:15.0, name:iPad Pro (12.9-inch) (5th generation) }
    { platform:iOS Simulator, id:8DE0D105-9E50-4DA6-BD87-DA381C590E8A, OS:15.0, name:iPad mini (6th generation) }
    { platform:iOS Simulator, id:89DA58EA-E4AA-4BD2-948B-76C6F7613CE6, OS:15.0, name:iPhone 8 }
    { platform:iOS Simulator, id:3FB087A2-4DEA-4972-A5C0-6B74CB4B3D4C, OS:15.0, name:iPhone 8 Plus }
    { platform:iOS Simulator, id:34C05C4F-ABF4-4D2C-8CFB-AB9D9F81496A, OS:15.0, name:iPhone 11 }
    { platform:iOS Simulator, id:E5EDE7A3-B3FA-4864-ACC3-E7FA1F8C689B, OS:15.0, name:iPhone 11 Pro }
    { platform:iOS Simulator, id:ED158108-0E9A-4AD4-BA76-14FB4B62AC5A, OS:15.0, name:iPhone 11 Pro Max }
    { platform:iOS Simulator, id:DB6EEF02-9DBC-4F5D-8FD5-679169A0EFA7, OS:15.0, name:iPhone 12 }
    { platform:iOS Simulator, id:E122CD45-51EF-45FE-8B51-D5798606BF7A, OS:15.0, name:iPhone 12 Pro }
    { platform:iOS Simulator, id:7415DE00-6657-4F0F-BB38-8EC58323F6FF, OS:15.0, name:iPhone 12 Pro Max }
    { platform:iOS Simulator, id:5487FAA8-0B72-4477-AD3F-F3F8DB3DDD04, OS:15.0, name:iPhone 12 mini }
    { platform:iOS Simulator, id:21F1617B-4715-4EC9-B15D-2DD55519E7D3, OS:15.0, name:iPhone 13 }
    { platform:iOS Simulator, id:D3BA25C2-DEE0-4E5E-BFA5-B5C3708809E3, OS:15.0, name:iPhone 13 Pro }
    { platform:iOS Simulator, id:089C91CB-D751-4AE0-9448-2FCAB72C7A12, OS:15.0, name:iPhone 13 Pro Max }
    { platform:iOS Simulator, id:F1A4CE57-775E-4753-98EB-EDBFF71FCE8C, OS:15.0, name:iPhone 13 mini }
    { platform:iOS Simulator, id:C20EA51A-A417-4464-BD51-CD58F0C012E3, OS:15.0, name:iPhone SE (2nd generation) }
    { platform:iOS Simulator, id:36BC4107-F7CA-4BA7-ADF7-60D2DD0F0E89, OS:15.0, name:iPod touch (7th generation) }
    { platform:macOS, arch:arm64, variant:Designed for [iPad,iPhone], id:00008103-001A28A41E53001E }
    { platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device }
    ** BUILD FAILED **
Xcode's output:
↳
    In file included from /Users/ravipenikelapati/FlutterDev/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-6.0.12/ios/Classes/FLTURLLauncherPlugin.m:7:
    /Users/ravipenikelapati/FlutterDev/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-6.0.12/ios/Classes/FLTURLLauncherPlugin.h:5:9: fatal error: 'Flutter/Flutter.h' file not found
    #import <Flutter/Flutter.h>
            ^~~~~~~~~~~~~~~~~~~
    1 error generated.
    note: Using new build system
    note: Planning
    note: Build preparation complete
    note: Building targets in parallel
Could not build the application for the simulator.
Error launching application on iPhone 13.
Exited (sigterm)

3

Answers


  1. This is happening because it can’t find flutter.h (the generated header file for iOS).

    Try running pod install after cleaning the project with flutter clean

    Login or Signup to reply.
  2. Posting as another answer as this seems possible answer and help others to see

    This should quite work:

    1. cd into ios directory (cd ios)
    2. pod deintegrate
    3. rm Flutter/Flutter.podspec
    4. rm podfile.lock
    5. flutter clean
    6. flutter run
    Login or Signup to reply.
  3. This is what worked for me:

    In Podfile:
    Replace

    post_install do |installer|
      installer.pods_project.targets.each do |target|
       target.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
       end
      end
     end
    

    By

    post_install do |installer| 
      installer.pods_project.targets.each do |target| 
        flutter_additional_ios_build_settings(target) 
      end 
    end
    

    Then open iOS file in Xcode, and in Pods, for each Target, in Build Settings, set deployment target to 11 (maybe 9 is enough)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search