Search code examples
iosfluttercocoapods

How to fix 'Flutter/Flutter.h' file not found


Last week when I last worked on this it was building ok. Stopped working on this while adding new feature to an other app, week-end break I come back and both app do not compile any more. one is complaing that it as a socket exeception, and the other one as the below problem.

Could not build the precompiled application for the device.
Lexical or Preprocessor Issue (Xcode): 'Flutter/Flutter.h' file not found
/Users/user/.pub-cache/hosted/pub.dev/flutter_blue_plus-1.32.7/ios/Classes/FlutterBluePlusPlugin.h:7:8

Lexical or Preprocessor Issue (Xcode): 'Flutter/Flutter.h' file not found
/Users/user/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/ios/Classes/FPPPackageInfoPlusPlugin.h:4:8

Uncategorized (Xcode): Command SwiftEmitModule failed with a nonzero exit code


Error launching application on AR18 iPhone.

I tried the usual stuff DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead in xcode 15 I even asked GPT for some help. Nothing as worked.

So to make a quick list. -fully remove the cocoa pods, re-istalled them and update the repo.

  • delete the ios folder to re-generate it.. a few times (just in case).
  • cleaned, and cleaned flutter and ios projects.
  • deleted xcode cache files.
  • change my pod file (see below)

Still not able to get the app to build.

Podfile

# Uncomment this line to define a global platform for your project
platform :ios, '13.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__))
  target 'RunnerTests' do
    inherit! :search_paths
  end
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'NO'
      config.build_settings['CLANG_ENABLE_MODULES'] = 'YES'
      config.build_settings['SWIFT_VERSION'] = '5.0'
    end
  end
end


-fully remove the cocoa pods, re-istalled them and update the repo.

  • delete the ios folder to re-generate it.. a few times (just in case).
  • cleaned, and cleaned flutter and ios projects.
  • deleted xcode cache files.
  • change my pod file

Solution

  • Make sure all the plugins are up-to-date and compatible with the flutter version you are using currently.