Home > database >  fatal error: 'Flutter/Flutter.h' file not found #import <Flutter/Flutter.h> on 2022
fatal error: 'Flutter/Flutter.h' file not found #import <Flutter/Flutter.h> on 2022

Time:02-17

I had used a lots and lots of solutions for the past 3 days, but still i couldn't get rid of this issue, please help me out.

Xcode's output:
↳
In file included from 
/Users/hxtreme/Desktop/MobileApp/flutter/.pub- 
cache/hosted/pub.dartlang.org/wakelock- 
0.5.6/ios/Classes/WakelockPlugin.m:1:
/Users/hxtreme/Desktop/MobileApp/flutter/.pub- 
cache/hosted/pub.dartlang.org/wakelock- 
0.5.6/ios/Classes/WakelockPlugin.h:1: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 dependency order
Could not build the application for the simulator.
Error launching application on iPhone 12 Pro.

Im using Flutter v2.8.1, i also tried with different versions like v2.5.1, v2.10.1, but no use... and also tried with various stackoverflow solutions but didn't helped me out.

POD FILE:

# Uncomment this line to define a global platform for your project
platform :ios, '15.2'

# 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.frameworks_group["iOS"]["MobileCoreServices.framework"].remove_from_project
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '15.2'
    end
  end
end

Thanks in Advance!

CodePudding user response:

Change your Podfile

from this

post_install do |installer|
  installer.pods_project.frameworks_group["iOS"]["MobileCoreServices.framework"].remove_from_project
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '15.2'
    end
  end
end

to this

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

CodePudding user response:

please try this steps:

  1. Backup Runner folder
  2. Delete the ios folder
  3. Go to a terminal and execute flutter create . in the flutter project folder
  4. Paste your Runner folder back into the ios folder
  5. pod deintegrate in the ios folder
  6. pod install also in the ios folder
  7. flutter clean in the flutter project folder
  8. flutter pub get
  9. flutter run

Please note that if you use firebase you need to re-insert the GoogleService-Info.plist file

  • Related