Flutter: include of non-modular header inside framework module 'firebase_core.FLTFirebasePlugin'
Asked Answered
A

4

11

I have been trying to run my Flutter code on IOS device. However I am getting some errors regarding non-modular headers inside Framework module.

Logs:

While building module 'firebase_core' imported from
/Users/admin/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/fi
rebase_auth-0.20.0+1/ios/Classes/FLTFirebaseAuthPlugin.m:5:
In file included from <module-includes>:1:
In file included from
/Users/admin/Desktop/Ali/GuestInMe/ios/Pods/Target Support
Files/firebase_core/firebase_core-umbrella.h:13:
In file included from
/Users/admin/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/fi
rebase_core-0.7.0/ios/Classes/FLTFirebaseCorePlugin.h:11:
/Users/admin/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/fi
rebase_core-0.7.0/ios/Classes/FLTFirebasePlugin.h:9:9: error:
include of non-modular header inside framework module
'firebase_core.FLTFirebasePlugin':
'/Users/admin/Desktop/Ali/GuestInMe/ios/Pods/Headers/Public/Firebase
Core/FirebaseCore.h'
[-Werror,-Wnon-modular-include-in-framework-module]
#import <FirebaseCore/FirebaseCore.h>
        ^
1 error generated.
/Users/admin/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/fi
rebase_auth-0.20.0+1/ios/Classes/FLTFirebaseAuthPlugin.m:5:9: fatal
error: could not build module 'firebase_core'
#import <firebase_core/FLTFirebasePluginRegistry.h>
 ~~~~~~~^
2 errors generated.
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description

Could not build the application for the simulator.
Error launching application on iPhone 12 Pro Max.

What I have tried:

  1. I tried to change build settings of Xcode and allow non-modular imports -> flutter clean -> pod install in ios folder -> flutter run

  2. Tried changing the file to public from project, but it already was public.

  3. Reinstall all the pod files.

    'firebase_core.FLTFirebasePlugin': Screenshot

Alyciaalyda answered 11/2, 2021 at 3:50 Comment(2)
I just had a nearly identical issue with the Facebook ShareKit SDK (github.com/facebook/facebook-ios-sdk/issues/1649) I wish I could give a solution, but I ended up creating a new flutter project (with Swift iOS project) and re-writing all my native code in Swift. I do not know if the solution was Swift vs Objective C, or a new Flutter project vs older (my project was 2 years old) I would suggest creating a new flutter project, including those dependencies, and building. If you get the same issues, open an issue with the Flutter team. If not, it is a config issue somewhere :-(Khamsin
Creating a new flutter project solved this issue for me as well. I just replaced the newly created ios folder into my old project though.Clairvoyance
A
7

What worked eventually:

  1. Put all the pubspec.yaml dependencies to the latest version.
  2. Delete pubspec.lock, Pods folder in ios and Podfile.lock
  3. Run flutter clean -> flutter pub get -> cd ios -> pod install -> cd .. -> flutter run

And you should be good to go

Alyciaalyda answered 12/2, 2021 at 11:7 Comment(0)
B
6

You can fix it by editing Podfile

post_install do |installer|
  installer.pods_project.build_configuration_list.build_configurations.each do |configuration|
    configuration.build_settings['CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES'] = 'YES'
  end
end
Bashemath answered 20/8, 2021 at 11:25 Comment(0)
L
4

For me the following solution solved the problem:

xCode -> Build Settings under Target ->

set Allow Non-modular Includes in Framework Modules to YES

And also I did the following actions:

Select the firebase_core-umbrella.h file in the project navigator. In the target membership area on the right there side there will be a drop down menu next to the target. Select public there (default value is project or private).

You have to do above action for all other files with .h that are in error message.

Lyautey answered 28/6, 2024 at 9:54 Comment(0)
R
1

After spending a lot of time to resolve this problem and a similar ones like:

Include of non-modular header inside framework module 'firebase_auth.FLTAuthStateChannelStreamHandler'`

I found how to resolve it after searching all net.

  1. Be sure that your pubspec.yaml files are up to date to the latest version. If they are not please check pub.dev to find latest versions of your Firebase package.

  2. Add a 2 build parameters to your Build Settings inside Targets in Xcode
    For more information you can check this image

    1. ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES and set it to YES
    2. CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES and set it to YES

Hope it will help you!

Rothschild answered 19/7, 2024 at 0:42 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.