Skip to content
TheChatArchiveThe Chat Archive
gpt-4.1-mini-2025-04-14· OpenAIAi2 WildChat-4.8M (AI2)

Could not build the precompiled application for the device. Lexical or Preprocessor…

  1. 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

  2. Assistant

    It looks like you are facing a build error related to the firebase_messaging plugin 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/Podfile and make sure you add or modify the pod declarations 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!
    end
    

    Try adding :modular_headers => true to the Firebase pods or enable modular headers globally by adding use_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 get
    

    In 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_messaging 14.7.10 — confirm it's compatible with your Flutter and iOS SDK versions.

    Sometimes upgrading/downgrading firebase_messaging to 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
    end
    

    This setting allows non-modular includes inside framework modules, which can suppress this build error.


    Summary of steps to try:

    1. Modify ios/Podfile to add modular headers or allow non-modular includes.
    2. Run pod install --repo-update.
    3. Clean Flutter and Xcode build caches.
    4. Update Firebase pods to latest.
    5. 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!

  3. 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

  4. 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_install hook to allow non-modular includes

    Add the line to allow non-modular includes inside framework modules. Your current post_install block looks like this:

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

    Modify 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
    end
    

    This 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! or use_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__))
    end
    

    Then run pod install again.


    Summary:

    Update your Podfile's post_install like 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
    end
    

    Run clean commands and reinstall pods, then rebuild.


    If this still doesn’t fix it, please provide your flutter doctor -v output and the full Xcode build error log. This will help diagnose further.


    Hopefully this resolves the modular header issue!

  5. 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

  6. Assistant

    The error persists, meaning Xcode still sees Firebase.h as a non-modular header inside the firebase_messaging framework 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__))
    end
    

    This forces Pods to be statically linked frameworks — known to reduce these errors.

    After this change, run:

    cd ios
    pod install --repo-update
    

    Clean 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__))
    end
    

    Then:

    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 cocoapods
    

    Or if you use Homebrew:

    brew upgrade cocoapods
    

    Then run pod repo update and pod install again.


    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_messaging
    

    Make sure your Flutter SDK is at least 3.7+ for best integration.


    6. Add this to the post_install hook 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!

  7. 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

  8. 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 --version
    

    If it's below 1.16.2, proceed.


    Step 2: Update CocoaPods

    If you installed CocoaPods via Ruby gem (default):

    Run:

    sudo gem install cocoapods
    

    This installs the latest stable version.

    Important: If you run into permission or environment issues, you might want to use a Ruby version manager (like rbenv or rvm), but for most setups sudo gem install cocoapods suffices.


    If you installed CocoaPods using Homebrew (macOS):

    Run:

    brew upgrade cocoapods
    

    or to install if missing:

    brew install cocoapods
    

    Step 3: Verify installation

    After update, verify the version:

    pod --version
    

    You 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 ios folder 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!

  9. User

    Ignoring ffi-1.16.3 because its extensions are not built. Try: gem pristine ffi --version 1.16.3

  10. Assistant

    The message:

    Ignoring ffi-1.16.3 because its extensions are not built. Try: gem pristine ffi --version 1.16.3
    

    indicates the Ruby ffi gem — 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.3
    

    If 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?

    ffi gem 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 --version
    

    And ensure CocoaPods works by running:

    pod install --repo-update
    

    Quick checklist:

    1. gem pristine ffi --version 1.16.3 (or sudo)
    2. Restart your terminal/session (sometimes needed)
    3. pod --version
    4. pod install --repo-update in your iOS folder.

    Let me know if you encounter errors during these steps!