Could not build the precompiled application for the device. Lexical or Preprocessor…
- User
Could not build the precompiled application for the device. Lexical or Preprocessor Issue (Xcode): Include of non-modular header inside framework module 'firebase_messaging.FLTFirebaseMessagingPlugin': '/Users/mac/Desktop/ /ios/Pods/Headers/Public/Firebase/Firebase.h' /Users/mac/.pub-cache/hosted/pub.dev/firebase_messaging-14.7.10/ios/Classes/FLTF irebaseMessagingPlugin.h:11:8
- Assistant
It looks like you are facing a build error related to the
firebase_messagingplugin in your Flutter iOS project. The error:Lexical or Preprocessor Issue (Xcode): Include of non-modular header inside framework module 'firebase_messaging.FLTFirebaseMessagingPlugin': '/Users/mac/Desktop/ /ios/Pods/Headers/Public/Firebase/Firebase.h'indicates that Xcode is having trouble including the Firebase headers in a modular way inside your plugin, which causes the build to fail.
This is a common problem when mixing CocoaPods and Swift/Objective-C frameworks that are not configured to be modular.
How to fix this issue?
1. Enable Modular Headers in Podfile
Open your
ios/Podfileand make sure you add or modify thepoddeclarations related to Firebase to use modular headers.Example Podfile snippet:
platform :ios, '11.0' # Add these lines if not present: use_frameworks! :linkage => :static target 'Runner' do flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) # Explicitly add modular headers for Firebase pods: pod 'Firebase', :modular_headers => true pod 'FirebaseMessaging', :modular_headers => true # or try enabling modular headers for all pods: # use_modular_headers! endTry adding
:modular_headers => trueto the Firebase pods or enable modular headers globally by addinguse_modular_headers!inside the target block. This allows Firebase headers to be treated modularly and imported correctly by Xcode.After modifying the Podfile:
cd ios pod install --repo-update
2. Clean Xcode Build & Flutter Cache
Run the following commands to clean old builds and caches:
flutter clean rm -rf ios/Pods ios/Podfile.lock cd ios pod install --repo-update cd .. flutter pub getIn Xcode, also do Product > Clean Build Folder before rebuilding.
3. Ensure Firebase iOS SDK is up to date
Make sure your Firebase dependent pods are the latest version so that modular header support is present:
pod update Firebase FirebaseMessaging
4. Check your Flutterfire plugin version
You've mentioned using
firebase_messaging14.7.10 — confirm it's compatible with your Flutter and iOS SDK versions.Sometimes upgrading/downgrading
firebase_messagingto a version compatible with your Flutter and iOS setup helps.
5. Other workarounds
- Sometimes, adding the following to your Podfile's post_install step helps:
post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES'] = 'YES' end end endThis setting allows non-modular includes inside framework modules, which can suppress this build error.
Summary of steps to try:
- Modify
ios/Podfileto add modular headers or allow non-modular includes. - Run
pod install --repo-update. - Clean Flutter and Xcode build caches.
- Update Firebase pods to latest.
- Rebuild.
If you still face issues, please share:
- Your
Podfile - Your Flutter version (
flutter doctor -v) - Full build logs (preferably from Xcode)
I can help you debug further then!
- User
Uncomment this line to define a global platform for your project
platform :ios, '14.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! pod 'AppLovinSDK' pod 'AppLovinMediationFacebookAdapter' 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
- Assistant
Thanks for sharing your Podfile. You already have these important lines:
use_frameworks! use_modular_headers!This means CocoaPods will use frameworks with modular headers enabled, which is usually good.
Next steps to fix the
'Include of non-modular header inside framework module'error:
1. Modify your
post_installhook to allow non-modular includesAdd the line to allow non-modular includes inside framework modules. Your current
post_installblock looks like this:post_install do |installer| installer.pods_project.targets.each do |target| flutter_additional_ios_build_settings(target) end endModify it to:
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['CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES'] = 'YES' end end endThis setting explicitly allows non-modular headers within framework modules and can resolve this error without changing much else.
2. Clean and reinstall pods with Flutter clean
Make sure to run these commands from your project root:
flutter clean rm -rf ios/Pods ios/Podfile.lock flutter pub get cd ios pod install --repo-update cd ..Then rebuild your iOS app.
3. Make sure your Podfile does not have duplicate or conflicting
use_frameworks!oruse_modular_headers!You only need:
use_frameworks! use_modular_headers!inside your target block — your Podfile looks fine in this part.
4. Verify Firebase pod versions (optional)
If the above doesn't work, you can explicitly add Firebase pods with modular headers:
target 'Runner' do use_frameworks! use_modular_headers! pod 'FirebaseCore', :modular_headers => true pod 'FirebaseMessaging', :modular_headers => true flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) endThen run
pod installagain.
Summary:
Update your Podfile's
post_installlike this: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['CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES'] = 'YES' end end endRun clean commands and reinstall pods, then rebuild.
If this still doesn’t fix it, please provide your
flutter doctor -voutput and the full Xcode build error log. This will help diagnose further.
Hopefully this resolves the modular header issue!
- User
Could not build the precompiled application for the device. Lexical or Preprocessor Issue (Xcode): Include of non-modular header inside framework module 'firebase_messaging.FLTFirebaseMessagingPlugin': '/Users/mac/Desktop/taw3iav1.7.0/ios/Pods/Headers/Public/Firebase/Firebase.h' /Users/mac/.pub-cache/hosted/pub.dev/firebase_messaging-14.7.10/ios/Classes/FLTF irebaseMessagingPlugin.h:11:8
- Assistant
The error persists, meaning Xcode still sees
Firebase.has a non-modular header inside thefirebase_messagingframework module.
Since you already have:
use_frameworks!use_modular_headers!- The post_install fix to allow non-modular includes
Let's try some additional steps to resolve this:
1. Use static linking for frameworks instead of dynamic
Modular header issues often happen when
use_frameworks!uses dynamic frameworks. Since Flutter 3.7+, static linking is better supported.Update your Podfile target block to:
target 'Runner' do use_frameworks! :linkage => :static use_modular_headers! pod 'AppLovinSDK' pod 'AppLovinMediationFacebookAdapter' flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) endThis forces Pods to be statically linked frameworks — known to reduce these errors.
After this change, run:
cd ios pod install --repo-updateClean build as usual.
2. Explicitly add Firebase pods with modular headers
In rare cases, flutter_install_all_ios_pods doesn't explicitly add Firebase pods with modular headers, and that can cause problems.
Try explicitly adding FirebaseCore and FirebaseMessaging pods in the Podfile:
target 'Runner' do use_frameworks! :linkage => :static use_modular_headers! pod 'FirebaseCore', :modular_headers => true pod 'FirebaseMessaging', :modular_headers => true pod 'AppLovinSDK' pod 'AppLovinMediationFacebookAdapter' flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) endThen:
cd ios pod install --repo-update
3. Clear Derived Data
Sometimes Xcode caches cause issues.
- Open Xcode
- Go to Xcode > Preferences > Locations
- Click the arrow next to Derived Data and delete the contents inside the folder.
4. Update your CocoaPods gem if outdated
Ensure CocoaPods is latest:
sudo gem install cocoapodsOr if you use Homebrew:
brew upgrade cocoapodsThen run
pod repo updateandpod installagain.
5. Verify your Firebase Messaging plugin version matches your Flutter SDK
You can try a newer version than
14.7.10(if available):flutter pub upgrade firebase_messagingMake sure your Flutter SDK is at least 3.7+ for best integration.
6. Add this to the
post_installhook if not done yet:post_install do |installer| installer.pods_project.targets.each do |target| flutter_additional_ios_build_settings(target) target.build_configurations.each do |config| # Allow non-modular includes inside framework modules config.build_settings['CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES'] = 'YES' end end end
Summary of Podfile example:
platform :ios, '14.0' ENV['COCOAPODS_DISABLE_STATS'] = 'true' target 'Runner' do use_frameworks! :linkage => :static use_modular_headers! pod 'FirebaseCore', :modular_headers => true pod 'FirebaseMessaging', :modular_headers => true pod 'AppLovinSDK' pod 'AppLovinMediationFacebookAdapter' 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) target.build_configurations.each do |config| config.build_settings['CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES'] = 'YES' end end end
After that run:
flutter clean flutter pub get cd ios pod install --repo-update cd .. flutter run
If this still doesn't work, please share:
- Your Flutter version:
flutter doctor -v - The full
Podfile - Full Xcode build output (copy/paste from Xcode or build logs)
I can help debug further!
- User
Warning: CocoaPods recommended version 1.16.2 or greater not installed. Pods handling may fail on some projects involving plugins. To update CocoaPods, see
- Assistant
The warning:
Warning: CocoaPods recommended version 1.16.2 or greater not installed. Pods handling may fail on some projects involving plugins.means your installed CocoaPods version is older than 1.16.2, and that could cause issues with handling modern Flutter plugins (like firebase_messaging).
How to update CocoaPods to the recommended version (or newer)
Step 1: Check your current CocoaPods version
Run:
pod --versionIf it's below 1.16.2, proceed.
Step 2: Update CocoaPods
If you installed CocoaPods via Ruby gem (default):
Run:
sudo gem install cocoapodsThis installs the latest stable version.
Important: If you run into permission or environment issues, you might want to use a Ruby version manager (like
rbenvorrvm), but for most setupssudo gem install cocoapodssuffices.
If you installed CocoaPods using Homebrew (macOS):
Run:
brew upgrade cocoapodsor to install if missing:
brew install cocoapods
Step 3: Verify installation
After update, verify the version:
pod --versionYou should see >= 1.16.2 (for Flutter, usually 1.11+ or 1.12+ is good).
Step 4: Reinstall your pods
After you update, go to your
iosfolder and reinstall pods:cd ios pod repo update pod install
Step 5: Clean Flutter project and build
To be sure:
flutter clean flutter pub get cd ios pod install cd .. flutter run
Summarizing:
Updating CocoaPods often fixes subtle pod integration issues that cause the non-modular header errors you're seeing with Firebase.
If you still encounter problems after updating, please provide:
- The fixed Podfile after changes.
- The full output of
pod --version. - Any updated build errors.
Let me know if you want the detailed steps for using a Ruby version manager or you run into issues updating CocoaPods!
- User
Ignoring ffi-1.16.3 because its extensions are not built. Try: gem pristine ffi --version 1.16.3
- Assistant
The message:
Ignoring ffi-1.16.3 because its extensions are not built. Try: gem pristine ffi --version 1.16.3indicates the Ruby
ffigem — which CocoaPods depends on — has not been properly built/compiled on your system. This often happens after upgrading Ruby or switching environments.Since CocoaPods depends on
ffi, this can cause CocoaPods commands to malfunction.
How to fix this:
Run the suggested command to rebuild the native extensions for ffi:
gem pristine ffi --version 1.16.3If you get permission errors, run with
sudo:sudo gem pristine ffi --version 1.16.3
If that doesn’t work, try reinstalling ffi:
sudo gem uninstall ffi sudo gem install ffi
Why does this happen?
ffigem includes C extensions that need to be compiled for your system architecture. If you updated Ruby or system libraries, the compiled extensions might be missing or broken.
After fixing
ffi, verify CocoaPods:Run:
pod --versionAnd ensure CocoaPods works by running:
pod install --repo-update
Quick checklist:
gem pristine ffi --version 1.16.3(orsudo)- Restart your terminal/session (sometimes needed)
pod --versionpod install --repo-updatein your iOS folder.
Let me know if you encounter errors during these steps!