fatal error: 'Flutter/Flutter.h' file not found
Describe the bug
I am currently working on a Flutter project, which was functioning correctly. However, I have been attempting to run the project for the past two days, and I am consistently encountering the same error message: “Fatal error: ‘Flutter/Flutter.h’ file not found in flutter_local_notifications.” Despite my efforts to resolve this issue, I have exhausted all known solutions, including cleaning the project thoroughly and ensuring that all necessary updates have been applied.
The debug console log
Launching lib/main.dart on Arivan’s iPhone (wireless) in debug mode...
Automatically signing iOS for device deployment using specified development team in Xcode project: 57NVLUMP75
Xcode build done. 35.8s
Failed to build iOS app
Could not build the precompiled application for the device.
Swift Compiler Error (Xcode): Clang dependency scanner failure: While building module 'flutter_local_notifications' imported from flutter_local_notifications-41df224b.input:1:
In file included from <module-includes>:1:
In file included from /Users/arivan-blackace/Projects/city_star_flutter/build/ios/Debug-iphoneos/flutter_local_notifications/flutter_local_notifications.framework/Headers/flutter_local_notifications-umbrella.h:13:
/Users/arivan-blackace/Projects/city_star_flutter/build/ios/Debug-iphoneos/flutter_local_notifications/flutter_local_notifications.framework/Headers/ActionEventSink.h:13:9: fatal error: 'Flutter/Flutter.h' file not found
flutter_local_notifications-41df224b.input:1:1: fatal error: could not build module 'flutter_local_notifications'
2
Swift Compiler Error (Xcode): Unable to find module dependency: 'Flutter'
import Flutter
^
/Users/arivan-blackace/Projects/city_star_flutter/ios/Runner/AppDelegate.swift:0:7
Swift Compiler Error (Xcode): Unable to find module dependency: 'flutter_local_notifications'
import flutter_local_notifications
^
/Users/arivan-blackace/Projects/city_star_flutter/ios/Runner/AppDelegate.swift:5:7
Swift Compiler Error (Xcode): Bridging header dependency scan failure: In file included from /Users/arivan-blackace/Projects/city_star_flutter/ios/Runner/Runner-Bridging-Header.h:1:
/Users/arivan-blackace/Projects/city_star_flutter/ios/Runner/GeneratedPluginRegistrant.h:10:9: fatal error: 'Flutter/Flutter.h' file not found
3
Error launching application on Arivan’s iPhone (wireless).
Exited (1).
Podfile
# Uncomment this line to define a global platform for your project
platform :ios, '15.5'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
$iOSVersion = '15.5'
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!
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.build_configurations.each do |config|
config.build_settings["EXCLUDED_ARCHS[sdk=*]"] = "armv7"
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = $iOSVersion
end
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
# You can remove unused permissions here
# for more information: https://github.com/Baseflow/flutter-permission-handler/blob/main/permission_handler_apple/ios/Classes/PermissionHandlerEnums.h
# e.g. when you don't need camera permission, just add 'PERMISSION_CAMERA=0'
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',
## dart: PermissionGroup.location
'PERMISSION_LOCATION=1',
'PERMISSION_LOCATION_ALWAYS=1',
'PERMISSION_LOCATION_WHENINUSE=1',
## dart: PermissionGroup.notification
'PERMISSION_NOTIFICATIONS=1',
## dart: PermissionGroup.appTrackingTransparency
'PERMISSION_APP_TRACKING_TRANSPARENCY=1',
]
# Fix for Firebase and iOS 15.5+
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = $iOSVersion
end
# Fix for Firebase Core Plugin
if target.name == 'firebase_core'
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
end
end
end
pubspec.yaml
name: flutter app
description: "description"
publish_to: "none"
version: 0.10.5+59
environment:
sdk: ">=3.3.3 <4.0.0"
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
intl: ^0.20.2
# Firebase
firebase_core: ^4.1.1
firebase_app_check: ^0.4.1
firebase_messaging: ^16.0.2
firebase_analytics: ^12.0.2
firebase_crashlytics: ^5.0.2
firebase_performance: ^0.11.1
recaptcha_enterprise_flutter: ^18.8.0
google_sign_in: ^7.2.0
sign_in_with_apple: ^7.0.1
# TODO: Uncomment when Facebook sign-in is needed
# flutter_facebook_auth: ^7.1.2
# General
provider: ^6.1.5
http: ^1.5.0
socket_io_client: ^3.1.2
hive: ^2.2.3
hive_flutter: ^1.1.0
google_maps_flutter: ^2.13.1
geolocator: ^14.0.2
flutter_polyline_points: ^2.1.0
# connectivity_plus: ^6.1.0
url_launcher: ^6.3.2
package_info_plus: ^8.3.0
image_picker: ^1.2.0
in_app_update: ^4.2.5
permission_handler: ^12.0.1
flutter_local_notifications: ^19.3.1
app_badge_plus: ^1.2.3
photo_view: ^0.15.0
cached_network_image: ^3.4.1
octo_image: ^2.1.0
flutter_blurhash: ^0.9.1
in_app_review: ^2.0.11
flutter_rating_bar: ^4.0.1
flutter_native_splash: ^2.4.6
flutter_svg: ^2.2.1
mobile_scanner: ^7.1.2
auto_size_text: ^3.0.0
file_picker: ^10.3.3
# UI
carousel_slider_plus: ^7.1.1
pin_code_fields: ^8.0.1
flexible_scrollbar: ^0.1.3
# HTML
flutter_widget_from_html_core: ^0.17.0
fwfh_webview: ^0.15.6
fwfh_url_launcher: ^0.16.1
fwfh_cached_network_image: ^0.16.1
# Animations
flutter_animate: ^4.5.2
auto_animated: ^3.2.0
flutter_staggered_animations: ^1.1.1
animated_flip_counter: ^0.3.4
# Icons
font_awesome_flutter: ^10.8.0
# Referenced
crypto: ^3.0.6
http_parser: ^4.1.2
cupertino_icons: ^1.0.8
flutter_cache_manager: ^3.4.1
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^6.0.0
flutter_launcher_icons: ^0.14.4
flutter:
generate: true
uses-material-design: true
assets:
- assets/
- assets/logo/
- assets/images/
fonts:
- family: Rebar
fonts:
- asset: assets/fonts/Rabar-Regular.ttf
- asset: assets/fonts/Rabar-Bold.ttf
weight: 700
flutter_intl:
enabled: true
arb_dir: lib/localization/l10n
output_dir: lib/localization/generated
AppDelegate.swift
import Flutter
import UIKit
import GoogleMaps
import Firebase
import FirebaseAnalytics
import flutter_local_notifications
@main
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
// Configure Firebase first
FirebaseApp.configure()
// Disable automatic data collection initially (will be enabled after ATT permission)
Analytics.setAnalyticsCollectionEnabled(false)
//Start of other configs
FlutterLocalNotificationsPlugin.setPluginRegistrantCallback { (registry) in
GeneratedPluginRegistrant.register(with: registry)
}
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as UNUserNotificationCenterDelegate
}
GMSServices.provideAPIKey("KEY")
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
Things i tried
I run the command below to fix the issue but no use
flutter clean
cd ios
rm -rf Pods
rm Podfile.lock
cd ..
flutter pub get
cd ios
pod deintegrate
pod repo update
pod install
cd ..
Final way i tried:
cd ios
rm -rf Runner.xcworkspace
rm -rf Pods
rm Podfile.lock
cd ..
flutter clean
flutter pub get
cd ios
pod install
cd ..
flutter run
I am having the same issue. Tried clearing the project and reinstalling pods many times, even tried SPM. Did you ever come up with a solution?
I’m still facing that issue, and I don’t know how to fix it.
I am also having this issue. Have run through many potential solutions with no luck.
Same here, unable to find a solution or mitigation :(
Unfortunately I don't have any advice I can give on this. Currently, it looks like there's a problem with resolving Flutter itself as well. but I don't know what the cause here would be and is typically environment-specific. Would anyone have a link to a repository hosting a minimal app that can reproduce this problem? Additionally, does this problem also occur if you use an external service to build your app?