invertase / react-native-firebase

🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.71k stars 2.22k forks source link

[🐛] 🔥 "Include of non-modular header inside framework module" error after adding "use_frameworks! :linkage => :static" #6933

Closed bmitioglov closed 1 year ago

bmitioglov commented 1 year ago

Issue

Hello, I am following setup steps, I have a bare react native project after I ejected from expo. I have added use_frameworks! :linkage => :static this line to Podfile targets as mentioned in the setup guide. After that I started seeing the following error: Include of non-modular header inside framework module 'ExpoModulesCore.EXPermissionsInterface' on the line #import <UMCore/UMModuleRegistry.h> in EXPermissionsInterface.h file.


Project Files

Podfile:

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/react-native-unimodules/cocoapods.rb'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '12.0'

target 'PumpX' do
  use_unimodules!

  config = use_native_modules!

  use_react_native!(:path => config["reactNativePath"])

  use_frameworks! :linkage => :static
  $RNFirebaseAsStaticFramework = true

  # Uncomment to opt-in to using Flipper
  #
  # if !ENV['CI']
  #   use_flipper!('Flipper' => '0.75.1', 'Flipper-Folly' => '2.5.3', 'Flipper-RSocket' => '1.3.1')
  #   post_install do |installer|
  #     flipper_post_install(installer)
  #   end
  # end
end

target 'OneSignalNotificationServiceExtension' do
  pod 'OneSignalXCFramework', '>= 3.0', '< 4.0'
  use_frameworks! :linkage => :static
   $RNFirebaseAsStaticFramework = true
end

Javascript

Click To Expand

#### `package.json`: ```json { "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "lint": "eslint .", "start": "react-native start", "test": "jest" }, "dependencies": { "@invertase/react-native-apple-authentication": "^2.2.2", "@react-native-camera-roll/camera-roll": "^5.2.3", "@react-native-clipboard/clipboard": "^1.11.1", "@react-native-community/datetimepicker": "^3.5.2", "@react-native-community/masked-view": "^0.1.11", "@react-native-community/netinfo": "^7.1.12", "@react-navigation/bottom-tabs": "^6.0.9", "@react-navigation/elements": "^1.3.1", "@react-navigation/native": "^6.0.6", "@react-navigation/native-stack": "^6.2.5", "@react-navigation/stack": "^6.0.11", "@stream-io/flat-list-mvcp": "^0.10.2", "axios": "^0.21.4", "expo": "~42.0.1", "expo-font": "~9.2.1", "expo-in-app-purchases": "~11.0.1", "expo-secure-store": "~10.2.0", "expo-updates": "~0.8.2", "react": "16.13.1", "react-dom": "16.13.1", "react-native": "~0.63.4", "react-native-date-picker": "^4.1.1", "react-native-document-picker": "^8.1.3", "react-native-elements": "^3.4.2", "react-native-form-select-picker": "^0.0.12", "react-native-fs": "^2.20.0", "react-native-gesture-handler": "~2.9.0", "react-native-haptic-feedback": "^1.14.0", "react-native-hyperlink": "^0.0.22", "react-native-image-crop-picker": "^0.39.0", "react-native-image-resizer": "^1.4.5", "react-native-in-app-review": "^4.1.1", "react-native-linear-gradient": "~2.5.6", "react-native-localize": "^2.2.4", "react-native-maps": "^0.28.0", "react-native-modal": "^12.1.0", "react-native-number-please": "^1.0.5", "react-native-onesignal": "^4.3.11", "react-native-picker-select": "^8.0.4", "react-native-reanimated": "~2.2.0", "react-native-responsive-linechart": "^5.7.1", "react-native-safe-area-context": "3.2.0", "react-native-screens": "~3.4.0", "react-native-sectioned-multi-select": "^0.8.1", "react-native-share": "^8.1.0", "react-native-snap-carousel": "^3.9.1", "react-native-splash-screen": "^3.3.0", "react-native-svg": "^12.5.1", "react-native-swipe-list-view": "^3.2.9", "react-native-swiper": "^1.6.0", "react-native-switch-selector": "^2.2.0", "react-native-unimodules": "0.14.10", "react-native-uuid": "^2.0.1", "react-native-vector-icons": "^9.1.0", "react-native-video": "^5.2.1", "react-native-walkthrough-tooltip": "^1.3.1", "react-native-web": "~0.11.0", "react-native-webview": "~11.0.0", "react-native-youtube-iframe": "^2.2.2", "react-redux": "^7.2.5", "redux": "^4.1.1", "redux-thunk": "^2.4.1", "stream-chat-react-native": "^5.9.0" }, "devDependencies": { "@babel/core": "^7.9.0" }, "private": true, "name": "gymprogresstracker", "version": "1.0.0" } ``` #### `firebase.json` for react-native-firebase v6: ```json # N/A ```

iOS

Click To Expand

#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like: ```ruby require_relative '../node_modules/react-native/scripts/react_native_pods' require_relative '../node_modules/react-native-unimodules/cocoapods.rb' require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' platform :ios, '12.0' target 'PumpX' do use_unimodules! config = use_native_modules! # use_modular_headers! use_react_native!(:path => config["reactNativePath"]) use_frameworks! :linkage => :static $RNFirebaseAsStaticFramework = true # Uncomment to opt-in to using Flipper # # if !ENV['CI'] # use_flipper!('Flipper' => '0.75.1', 'Flipper-Folly' => '2.5.3', 'Flipper-RSocket' => '1.3.1') # post_install do |installer| # flipper_post_install(installer) # end # end end target 'OneSignalNotificationServiceExtension' do pod 'OneSignalXCFramework', '>= 3.0', '< 4.0' use_frameworks! :linkage => :static $RNFirebaseAsStaticFramework = true end ``` #### `AppDelegate.m`: ```objc #import "AppDelegate.h" //#import #if RCT_DEV #import #endif #import #import #import #import #import #import #import #import #import "RNSplashScreen.h" //#import #import //#if defined(FB_SONARKIT_ENABLED) && __has_include() //#import //#import //#import //#import //#import //#import #import "RNSplashScreen.h" //static void InitializeFlipper(UIApplication *application) { // FlipperClient *client = [FlipperClient sharedClient]; // SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults]; // [client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]]; // [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]]; // [client addPlugin:[FlipperKitReactPlugin new]]; // [client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]]; // [client start]; //} //#endif @interface AppDelegate () @property (nonatomic, strong) UMModuleRegistryAdapter *moduleRegistryAdapter; @property (nonatomic, strong) NSDictionary *launchOptions; @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // [FIRApp configure]; //#if defined(FB_SONARKIT_ENABLED) && __has_include() // InitializeFlipper(application); //#endif self.moduleRegistryAdapter = [[UMModuleRegistryAdapter alloc] initWithModuleRegistryProvider:[[UMModuleRegistryProvider alloc] init]]; self.launchOptions = launchOptions; self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; #ifdef DEBUG [self initializeReactNativeApp]; #else EXUpdatesAppController *controller = [EXUpdatesAppController sharedInstance]; controller.delegate = self; [controller startAndShowLaunchScreen:self.window]; #endif [super application:application didFinishLaunchingWithOptions:launchOptions]; // Set the splash screen to show by default. // RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:self.launchOptions]; // RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"main" initialProperties:nil]; // rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; // UIViewController *rootViewController = [UIViewController new]; // rootViewController.view = rootView; // self.window.rootViewController = rootViewController; // [self.window makeKeyAndVisible]; // [RNSplashScreen showSplash:@"LaunchScreen" inRootView:rootViewController.view]; // [RNSplashScreen showSplash:@"LaunchScreen" inRootView:rootView]; [RNSplashScreen show]; return YES; } - (RCTBridge *)initializeReactNativeApp { RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:self.launchOptions]; #if RCT_DEV [bridge moduleForClass:[RCTDevLoadingView class]]; #endif RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"main" initialProperties:nil]; rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; UIViewController *rootViewController = [UIViewController new]; rootViewController.view = rootView; self.window.rootViewController = rootViewController; [self.window makeKeyAndVisible]; // EXSplashScreenService *splashScreenService = (EXSplashScreenService *)[UMModuleRegistryProvider getSingletonModuleForClass:[EXSplashScreenService class]]; // [splashScreenService showSplashScreenFor:rootViewController]; // [RNSplashScreen show]; return bridge; } - (NSArray> *)extraModulesForBridge:(RCTBridge *)bridge { NSArray> *extraModules = [_moduleRegistryAdapter extraModulesForBridge:bridge]; // If you'd like to export some custom RCTBridgeModules that are not Expo modules, add them here! return extraModules; } - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge { #ifdef DEBUG return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; #else return [[EXUpdatesAppController sharedInstance] launchAssetUrl]; #endif } - (void)appController:(EXUpdatesAppController *)appController didStartWithSuccess:(BOOL)success { appController.bridge = [self initializeReactNativeApp]; // EXSplashScreenService *splashScreenService = (EXSplashScreenService *)[UMModuleRegistryProvider getSingletonModuleForClass:[EXSplashScreenService class]]; // [splashScreenService showSplashScreenFor:self.window.rootViewController]; } // Linking API - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary *)options { return [RCTLinkingManager application:application openURL:url options:options]; } // Universal Links - (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray> * _Nullable))restorationHandler { return [RCTLinkingManager application:application continueUserActivity:userActivity restorationHandler:restorationHandler]; } @end ```


Environment

Click To Expand

**`react-native info` output:** ``` info Fetching system and libraries information... System: OS: macOS 12.0.1 CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz Memory: 171.93 MB / 32.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 19.6.0 - /usr/local/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 9.4.0 - /usr/local/bin/npm Watchman: 2023.02.06.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.3 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5 Android SDK: Not Found IDEs: Android Studio: 2021.1 AI-211.7628.21.2111.8193401 Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild Languages: Java: 11.0.13 - /usr/bin/javac Python: 2.7.18 - /usr/bin/python npmPackages: @react-native-community/cli: Not Found react: Not Found react-native: Not Found react-native-macos: Not Found npmGlobalPackages: *react-native*: Not Found ``` - **Platform that you're experiencing the issue on**: - [x] iOS - [ ] Android - [ ] **iOS** but have not tested behavior on Android - [ ] **Android** but have not tested behavior on iOS - [ ] Both - **`react-native-firebase` version you're using that has this issue:** - `17.3.1` - **`Firebase` module(s) you're using that has the issue:** - `app` - **Are you using `TypeScript`?** - `N`


mikehardy commented 1 year ago

It sounds like this module is not compatible with use_frameworks, and there should be an issue filed in whatever repo hosts it:

Include of non-modular header inside framework module 'ExpoModulesCore.EXPermissionsInterface' on the line #import <UMCore/UMModuleRegistry.h> in EXPermissionsInterface.h file.

This is out of our control - our underlying SDK (firebase-ios-sdk) requires use_frameworks, so we must transitively require it. That module that is not working, is not in this repo, so this is not actionable here and there is not a lot we can do to help, apologies

safadl commented 1 year ago

Issue

Hello, I am following setup steps, I have a bare react native project after I ejected from expo. I have added use_frameworks! :linkage => :static this line to Podfile targets as mentioned in the setup guide. After that I started seeing the following error: Include of non-modular header inside framework module 'ExpoModulesCore.EXPermissionsInterface' on the line #import <UMCore/UMModuleRegistry.h> in EXPermissionsInterface.h file.

Project Files

Podfile:

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/react-native-unimodules/cocoapods.rb'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '12.0'

target 'PumpX' do
  use_unimodules!

  config = use_native_modules!

  use_react_native!(:path => config["reactNativePath"])

  use_frameworks! :linkage => :static
  $RNFirebaseAsStaticFramework = true

  # Uncomment to opt-in to using Flipper
  #
  # if !ENV['CI']
  #   use_flipper!('Flipper' => '0.75.1', 'Flipper-Folly' => '2.5.3', 'Flipper-RSocket' => '1.3.1')
  #   post_install do |installer|
  #     flipper_post_install(installer)
  #   end
  # end
end

target 'OneSignalNotificationServiceExtension' do
  pod 'OneSignalXCFramework', '>= 3.0', '< 4.0'
  use_frameworks! :linkage => :static
   $RNFirebaseAsStaticFramework = true
end

Javascript

Click To Expand

iOS

Click To Expand

Environment

Click To Expand

Did you find a solution?

endrits079 commented 1 year ago

Have you found a solution?

CoderLy0224 commented 11 months ago

Have you found a solution? thanks

KamilSikoraKellton commented 11 months ago

I also have this issue

mikehardy commented 11 months ago

In general this statement stands:

It sounds like this module is not compatible with use_frameworks, and there should be an issue filed in whatever repo hosts it:

If Expo's UMCore code isn't compatible with use_frameworks, then Expo needs to fix it.

Same with any module that has a compilation error with use_frameworks - use_frameworks is a valid way to compile Objective-C code and modules that do not handle it typically need a fix in how they import / use their header files.

Iamshivam-dev commented 2 months ago

I know I might be late, but if in future anyone come across this error, you can try following thing, i have spent entire day trying to find solution:

  1. Very basic, but try reinstalling pods, node modules, clear all cache.

  2. In you AppDelegate.mm, there is a method named didFinishLaunchingWithOptions, during installation of firebase you might have added below line to the method: [FIRApp configure];

For me the problem was this i didn't added this on the top of the method start, i added it right before return statement. So your didFinishLaunchingWithOptions should look like this:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  [FIRApp configure];

  // Other Code goes here---------------

  self.moduleName = @"MyApp";
  // You can add your custom initial props in the dictionary below.
  // They will be passed down to the ViewController used by React Native.
  self.initialProps = @{};

  return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
  1. You need use it as something like static Framework, i don't have much knowledge about this but here is what you have to do:
target 'MyApp Debug' do
  config = use_native_modules!

 # add below 2 lines 
  use_frameworks! :linkage => :static
  $RNFirebaseAsStaticFramework = true 
  post_install do |installer|
    # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
    react_native_post_install(
      installer,
      config[:reactNativePath],
      :mac_catalyst_enabled => false
    )

   # Add this code, its 3 lines, the last end is for post_install's do, don't get confused, 
    installer.pods_project.build_configurations.each do |config|
      config.build_settings["CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES"] = true
    end
  end

I really hope this helps someone. PS i don't have very much knowledge about native stuff of react native, this is what i did which worked for me.