React-native-firebase: 馃敟Xcode build for release throws 'Firebase.h' file not found in RNFirebaseUtil.h

Created on 18 Jul 2019  路  19Comments  路  Source: invertase/react-native-firebase


Issue


Xcode throws 'Firebase.h' file not found in RNFirebaseUtil.h file when building for release.

Describe your issue here


Project Files





iOS

Click To Expand

#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like:

# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'

target '$TARGET' do
  # Comment the next line if you don't want to use dynamic frameworks
  #use_frameworks!

  # Pods for '$TARGET'
  pod 'MoEngage-iOS-SDK','~> 4.4.0'
# Required by RNFirebase
pod 'Firebase/Core', '~> 6.3.0'

  target '$TARGET'-tvOSTests' do
    inherit! :search_paths
 end

  target '$TARGET'Tests' do
    inherit! :search_paths
    # Pods for testing
 end

end

#### `AppDelegate.m`:
/**
 * Copyright (c) 2015-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

#import "AppDelegate.h"
#import <Firebase.h>
#import <CodePush/CodePush.h>
#import <React/RCTPushNotificationManager.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#if __has_include(<React/RNSentry.h>)
#import <React/RNSentry.h> // This is used for versions of react >= 0.40
#else
#import "RNSentry.h" // This is used for versions of react < 0.40
#endif
#import <React/RCTLinkingManager.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#if RCT_DEV
#import <React/RCTDevLoadingView.h>
#endif

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  NSURL *jsCodeLocation;

  [FIRApp configure];
    #ifdef DEBUG
        jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
    #else
        jsCodeLocation = [CodePush bundleURL];
    #endif

  // The following two blocks of code (+ #import <React/RCTDevLoadingView.h> above) after seeing the 'RCTBridge required dispatch_sync to load RCTDevLoadingView. This may lead to deadlocks' warning. It stopped showing up after I brought back localhost to NSExceptionDomains this doesn't seem to show again. Leaving this here for now.
  // Previous to that, googling seems connected to react-native-device-info. A comment by devburmistro on https://github.com/facebook/react-native/issues/16376 suggested this fix.

//  RCTBridge *bridge = [[RCTBridge alloc] initWithBundleURL:jsCodeLocation
//                                            moduleProvider:nil
//                                             launchOptions:launchOptions];
//#if RCT_DEV
//  [bridge moduleForClass:[RCTDevLoadingView class]];
//#endif
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"Lifevision"
                                               initialProperties:nil
                                                   launchOptions:launchOptions];

  [RNSentry installWithRootView:rootView];

  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

  [[FBSDKApplicationDelegate sharedInstance] application:application
    didFinishLaunchingWithOptions:launchOptions];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  return YES;
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
    sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {

  BOOL handled = [[FBSDKApplicationDelegate sharedInstance] application:application
    openURL:url
    sourceApplication:sourceApplication
    annotation:annotation]
  ||
  [RCTLinkingManager application:application openURL:url
                                             sourceApplication:sourceApplication annotation:annotation];

  // Add any custom logic here.
  return handled;
}

 // Required to register for notifications

-(void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
  [RCTPushNotificationManager didRegisterUserNotificationSettings:notificationSettings];
}

 // Required for the register event.
-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
  [RCTPushNotificationManager didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}
 // Required for the notification event. You must call the completion handler after handling the remote notification.
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
    fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
  [RCTPushNotificationManager didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}
 // Required for the registrationError event.
-(void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
  [RCTPushNotificationManager didFailToRegisterForRemoteNotificationsWithError:error];
}
 // Required for the localNotification event.
-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
  [RCTPushNotificationManager didReceiveLocalNotification:notification];
}

-(BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler {
  return [RCTLinkingManager application:application
                   continueUserActivity:userActivity
                     restorationHandler:restorationHandler];
}
@end


Android

Click To Expand

#### Have you converted to AndroidX? - [ ] my application is an AndroidX application? - [ ] I am using `android/gradle.settings` `jetifier=true` for Android compatibility? - [ ] I am using the NPM package `jetifier` for react-native compatibility? #### `android/build.gradle`:

// N/A
#### `android/app/build.gradle`:
// N/A
#### `android/settings.gradle`:
// N/A
#### `MainApplication.java`:
// N/A
#### `AndroidManifest.xml`:
<!-- N/A -->


Environment

Click To Expand

**`react-native info` output:**

React Native Environment Info:
    System:
      OS: macOS 10.14.5
      CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
      Memory: 36.55 MB / 8.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 12.3.1 - /usr/local/bin/node
      Yarn: 1.16.0 - /usr/local/bin/yarn
      npm: 6.9.0 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
    IDEs:
      Android Studio: 3.4 AI-183.6156.11.34.5692245
      Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3 
      react-native: 0.59.8 => 0.59.8 
    npmGlobalPackages:
      react-native-cli: 2.0.1
- **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:** [email protected] - **`Firebase` module(s) you're using that has the issue:** Firebase CORE - **Are you using `TypeScript`?** - `Y`




Think react-native-firebase is great? Please consider supporting all of the project maintainers and contributors by donating via our Open Collective where all contributors can submit expenses. [Learn More]

Most helpful comment

Hey @awgeorge I'm suggesting something altogether different and possibly strange sounding :-). I'm suggesting actually moving that Podfile completely out of the way (mv ios/Podfile ios/Podfile.temp && react-native link react-native-firebase && mv ios/Podfile.temp ios/Podfile).

Reason: react-native link, if it detects you have a Podfile, will do a pod integration, whereas if it does not detect a Podfile it will link things into the .xcodeproj.

There is something wrong with the header paths in the .podspec for react-native-firebase in react-native 0.59 and it just doesn't work without some manual header copying, so you can't do that way easily and we recommend moving the Podfile aside.

This is something that seems important to fix, but with everything working perfectly on react-native 0.60, and a valid workaround, there's really no motivation.

Further, I will say that if you are on react-native 0.59, you should bump things up to current versions if at all possible - that's RNFB5.5.6, and firebase pods 6.8.1 (as of yesterday).

If you don't do that, you will likely be rejected from the App Store soon, as the firebase SDKs didn't remove all the UIWebView usage until just the 6.8.1 release on Sept 10th, and Apple has been issuing deprecation soon-to-be-rejected warnings about those UIWebView symbols.

All 19 comments

Blind guess: are you sure you opened the .xcworkspace file instead of the .xcproject?

@mikehardy yes I'm sure. I actually got past this by copying the header directories with post_install hook in the podfile as you suggested in another thread, but now I am getting FirebaseCore/FIRAnalyticsConfiguration.h not found.

Second blind guess (sorry - I'm traveling so not inspecting deeply) - is use_frameworks on in your Podfile? If so, check the PRs related to that very very recently and were part of the diff from v5.5.4 to v5.5.5 - v5.5.5 is not compatible with use_frameworks unfortunately but there is a workaround

@mikehardy I'm not using use_frameworks.

For what it's worth, I got the app to build, my temporary workaround

1)Downgrade to 5.3
2)Manually add ${SRCROOT}/../../../ios/Pods/Firebase to header search paths.
3)Manually add $(inherited) to framework search paths for target.

Would still be nice to get this solved for ^5.4

I actually got past this by copying the header directories with post_install hook in the podfile as you suggested in another thread, but now I am getting FirebaseCore/FIRAnalyticsConfiguration.h not found.

@DanKurf can you link to this other thread? Thanks

Hello 馃憢, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?

This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.

Having the same issue. Any update on the fix here?

Just stumbled into this too, has anybody found anything that can help?

Without versions or anything I can't say how to help you.
My comment above might be interesting.
Additionally, if you have not moved to auto-linking RN60+ then you will want to make sure that your Podfile (if you have one) is not in place when you do react-native link. We don't support linking into the Podfile in RN59 and lower, you have to link into the .xcodeproj which means no Podfile in place when you link.

Cheers Mike -

So we're using React 0.59.8, RNFirebase 5.4.2, Firebase/Core 5.20.2 trying to following the instructions here: https://rnfirebase.io/docs/v5.x.x/installation/ios, however we run react-native link react-native-firebase before pod install - are you suggesting to run pod install first?

Thanks.

Hey @awgeorge I'm suggesting something altogether different and possibly strange sounding :-). I'm suggesting actually moving that Podfile completely out of the way (mv ios/Podfile ios/Podfile.temp && react-native link react-native-firebase && mv ios/Podfile.temp ios/Podfile).

Reason: react-native link, if it detects you have a Podfile, will do a pod integration, whereas if it does not detect a Podfile it will link things into the .xcodeproj.

There is something wrong with the header paths in the .podspec for react-native-firebase in react-native 0.59 and it just doesn't work without some manual header copying, so you can't do that way easily and we recommend moving the Podfile aside.

This is something that seems important to fix, but with everything working perfectly on react-native 0.60, and a valid workaround, there's really no motivation.

Further, I will say that if you are on react-native 0.59, you should bump things up to current versions if at all possible - that's RNFB5.5.6, and firebase pods 6.8.1 (as of yesterday).

If you don't do that, you will likely be rejected from the App Store soon, as the firebase SDKs didn't remove all the UIWebView usage until just the 6.8.1 release on Sept 10th, and Apple has been issuing deprecation soon-to-be-rejected warnings about those UIWebView symbols.

@mikehardy Thanks for the info - that's a great note about the appstore listings. I'll try the podfile move and report back.

All sorted @mikehardy, thanks for your help and time. Much appreciated.

Great to hear! Good luck with your app

I am having the same error when I execute, on command line, "cordova build ios --release --device" and I am sure the compilation is using the .xcworkspace file. When I build the project from xCode is working ok.

Cordova version: 8.0.0 and 9.0.0
Ionic: 1.0.0
cordova-android: ^8.1.0
cordova-ios: ^5.1.1

This is the log ...

Checking config.xml for pods.
No new pods detects
Reading build config file: /mobile/build.json
Building project: /mobile/platforms/ios/MyProject.xcworkspace
    Configuration: Release
    Platform: device
    Target: 
Adding xcodebuildArg: -UseModernBuildSystem=0
Running command: xcodebuild -workspace MyProject.xcworkspace -scheme MyProject -configuration Release -destination generic/platform=iOS -archivePath MyProject.xcarchive archive CONFIGURATION_BUILD_DIR=/mobile/platforms/ios/build/device SHARED_PRECOMPS_DIR=/mobile/platforms/ios/build/sharedpch -UseModernBuildSystem=0
User defaults from command line:
    IDEArchivePathOverride = /mobile/platforms/ios/MyProject.xcarchive
    UseModernBuildSystem = 0

Build settings from command line:
    CONFIGURATION_BUILD_DIR = /mobile/platforms/ios/build/device
    SHARED_PRECOMPS_DIR = /mobile/platforms/ios/build/sharedpch

Prepare build
note: Using legacy build system

...

/mobile/platforms/ios/MyProject/Plugins/cordova-plugin-fcm-with-dependecy-updated/FCMPlugin.m:7:9: fatal error: 
      'Firebase.h' file not found
#import "Firebase.h"
        ^~~~~~~~~~~~
1 error generated.

** ARCHIVE FAILED **

The following build commands failed:
    CompileC /Users/myUser/Library/Developer/Xcode/DerivedData/MyProject-dwfxupwwzcbssmamqfftsijvblyb/Build/Intermediates.noindex/ArchiveIntermediates/MyProject/IntermediateBuildFilesPath/MyProject.build/Release-iphoneos/MyProject.build/Objects-normal/armv7/FCMPlugin.o MyProject/Plugins/cordova-plugin-fcm-with-dependecy-updated/FCMPlugin.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
(node:8380) UnhandledPromiseRejectionWarning: Error: xcodebuild: Command failed with exit code 65
    at ChildProcess.whenDone (/mobile/node_modules/cordova-common/src/superspawn.js:135:23)
    at ChildProcess.emit (events.js:197:13)
    at maybeClose (internal/child_process.js:984:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)
(node:8380) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:8380) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

All sorted @mikehardy, thanks for your help and time. Much appreciated.

Could you please write here the solution? I have the same issue.

@tdakanalis it is here https://github.com/invertase/react-native-firebase/issues/2375#issuecomment-530977568 but this is for older pre-0.60 react-natives. If you've upgraded in the last year to RN60 it's not needed

@yduartep Hello, Did you find any perfect solutions? I'm have a same problem right now.

Was this page helpful?
0 / 5 - 0 ratings