how do i resolve, "Lexical or Preprocessor Issue (Xcode): Flutter/Flutter.h' file not found"?

252

what i did was...

  • Updated Xcode to latest
  • change the minimum iOS version to 12 from Xcode/Runner/General/Deployment Info
  • then, pod deintegrate, install, update, repo update
  • flutter clean
  • flutter pub get

this solved the issue

Share:
252
Shaif Mohammad Reasat Dihan
Author by

Shaif Mohammad Reasat Dihan

Updated on January 04, 2023

Comments

  • Shaif Mohammad Reasat Dihan
    Shaif Mohammad Reasat Dihan over 1 year
         In file included from /Users/shaifdihan/development/flutter/.pub-cache/hosted/pub.dartlang.org/webview_flutter_wkwebview-2.7.1/ios/Classes/JavaScriptChannelHandler.m:5:
        /Users/shaifdihan/development/flutter/.pub-cache/hosted/pub.dartlang.org/webview_flutter_wkwebview-2.7.1/ios/Classes/JavaScriptChannelHandler.h:5:9: fatal error: 'Flutter/Flutter.h' file not found
        #import <Flutter/Flutter.h>
                ^~~~~~~~~~~~~~~~~~~
        1 error generated.
        note: Using new build system
        note: Building targets in parallel
        note: Planning build
        note: Analyzing workspace
        note: Constructing build description
        note: Build preparation complete
    /Users/shaifdihan/StudioProjects/my_match_flutter/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.5.99. (in target 'libPhoneNumber-iOS' from project 'Pods')
        .
        .
        .
    

    did eyery possible solution that i could find on the internet to solve the issue

    • pod deintegrate, install, update, repo update
    • delete iOS folder, flutter create ., copy Runner folder
    • flutter clean, flutter pub cache repair
    • project built with 2.5.3, checked with 2.10.3 also

    if i remove the webview_flutter plugin, sharedpreferences starts to show the same Flutter.h not found...then removed the sharedpreferences package, now Permission Handler package shows the same error!!

    My Podfile

    platform :ios, '11.0'
        
        # CocoaPods analytics sends network stats synchronously affecting flutter build latency.
        ENV['COCOAPODS_DISABLE_STATS'] = 'true'
        
        project 'Runner', {
          'Debug' => :debug,
          'Profile' => :release,
          'Release' => :release,
        }
        
        def flutter_root
          generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
          unless File.exist?(generated_xcode_build_settings_path)
            raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
          end
        
          File.foreach(generated_xcode_build_settings_path) do |line|
            matches = line.match(/FLUTTER_ROOT\=(.*)/)
            return matches[1].strip if matches
          end
          raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
        end
        
        require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
        
        flutter_ios_podfile_setup
        
        target 'Runner' do
          use_frameworks!
          use_modular_headers!
        
          flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
        end
        
        # post_install do |installer|
        #   installer.pods_project.targets.each do |target|
        #     flutter_additional_ios_build_settings(target)
        #   end
        # end
        post_install do |installer|
          installer.pods_project.targets.each do |target|
    #        flutter_additional_ios_build_settings(target)
            target.build_configurations.each do |config|
              config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = "arm64 i386"
            end
          end
        end
    

    flutter doctor -v

        [✓] Flutter (Channel stable, 2.5.3, on macOS 11.6.5 20G527 darwin-x64, locale en-GB)
        • Flutter version 2.5.3 at /Users/shaifdihan/development/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 18116933e7 (6 months ago), 2021-10-15 10:46:35 -0700
        • Engine revision d3ea636dc5
        • Dart version 2.14.4
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
        • Android SDK at /Users/shaifdihan/Library/Android/sdk
        • Platform android-32, 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 at /Applications/Xcode.app/Contents/Developer
        • Xcode 12.5.1, Build version 12E507
        • CocoaPods version 1.11.3
    
    [✓] 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.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)