react-native-firebase icon indicating copy to clipboard operation
react-native-firebase copied to clipboard

'RNFirebaseMessaging.h' file not found

Open joegoodall1 opened this issue 9 years ago • 22 comments

Environment:

Target Platform: iOS (iOS 9 - iPhone 8) Development Operating System: macOS Sierra Build tools: Xcode react-native: 0.50.3 "react-native-firebase": "3.1.0"

Everything works fine when the podfile is set up like this:

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

target 'MyApp' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for MyApp
  pod 'Firebase/Core'
  pod 'Firebase/Messaging'
  pod 'RNFirebase', :path => '../node_modules/react-native-firebase'
  pod "yoga", :path => "../node_modules/react-native/ReactCommon/yoga"
  pod 'React', :path => '../node_modules/react-native', :subspecs => [
  'BatchedBridge', # Required For React Native 0.45.0+
  'Core',
  'DevSupport'
  # Add any other subspecs you want to use in your project
  ]
end

I've followed the new instructions for installation and removed RNFirebase & React & Yoga from the podfile so it looks like this...

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

target 'MyApp' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for MyApp
  pod 'Firebase/Core'
  pod 'Firebase/Messaging'

end

...however, this causes XCode to fail with this error

/Users/ios/MyApp/AppDelegate.m:16:9: 'RNFirebaseMessaging.h' file not found

Have tried cleaning project and removing/reinstalling pods and node modules but no luck.

joegoodall1 avatar Nov 20 '17 23:11 joegoodall1

@joegoodall1 could you provide us with the code of your AppDelegate.m file also please, thanks

Salakar avatar Nov 21 '17 07:11 Salakar

@Salakar Thanks for the fast response.

Here's the AppDelegate.m

/**
 * Copyright (c) 2015-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */

#import "AppDelegate.h"
#import <CodePush/CodePush.h>

#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <Firebase.h>
#import "RNFirebaseMessaging.h"


@implementation AppDelegate

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

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

  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"Sitematch"
                                               initialProperties:nil
                                                   launchOptions:launchOptions];
  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

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

-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
  [RNFirebaseMessaging didReceiveLocalNotification:notification];
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo {
  [RNFirebaseMessaging didReceiveRemoteNotification:userInfo];
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo
fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{
  [RNFirebaseMessaging didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}

- (void)userNotificationCenter:(UNUserNotificationCenter *)center
       willPresentNotification:(UNNotification *)notification
         withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
  [RNFirebaseMessaging willPresentNotification:notification withCompletionHandler:completionHandler];
}

- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
         withCompletionHandler:(void (^)())completionHandler {
  [RNFirebaseMessaging didReceiveNotificationResponse:response withCompletionHandler:completionHandler];
}

@end

joegoodall1 avatar Nov 21 '17 11:11 joegoodall1

Hi @Salakar,

Any update on this?

joegoodall1 avatar Nov 22 '17 11:11 joegoodall1

@Salakar Have now got this working. Following the new install instructions (which have changed slightly from when we first installed react-native-firebase) seems to have sorted it.

joegoodall1 avatar Nov 23 '17 21:11 joegoodall1

@joegoodall1 how did you fix it ? i have the same issue.

hama avatar Dec 12 '17 16:12 hama

Me too

brunolemos avatar Dec 12 '17 17:12 brunolemos

@hama @brunolemos assuming you are using RN 0.50+, then please take a look at: https://github.com/invertase/react-native-firebase/issues/636

chrisbianca avatar Dec 12 '17 17:12 chrisbianca

@chrisbianca mine is 0.49.5

brunolemos avatar Dec 12 '17 17:12 brunolemos

Do you have RNFirebase listed in your Cocoapods? Or have you used react-native link?

chrisbianca avatar Dec 12 '17 17:12 chrisbianca

I used link. Tried this comment but didn't help.

Podfile
# Uncomment this line to define a global platform for your project
platform :ios, '8.0'

project 'Projectname.xcodeproj'

target 'Projectname' do

pod 'Firebase/Auth'
pod 'Firebase/Core'
pod 'Firebase/Messaging'
pod 'RSKImageCropper'
pod 'QBImagePickerController'

end
Podfile.lock
  - Firebase/Auth (4.7.0):
    - Firebase/Core
    - FirebaseAuth (= 4.4.0)
  - Firebase/Core (4.7.0):
    - FirebaseAnalytics (= 4.0.5)
    - FirebaseCore (= 4.0.12)
  - Firebase/Messaging (4.7.0):
    - Firebase/Core
    - FirebaseMessaging (= 2.0.7)
  - FirebaseAnalytics (4.0.5):
    - FirebaseCore (~> 4.0)
    - FirebaseInstanceID (~> 2.0)
    - GoogleToolboxForMac/NSData+zlib (~> 2.1)
    - nanopb (~> 0.3)
  - FirebaseAuth (4.4.0):
    - FirebaseAnalytics (~> 4.0)
    - GoogleToolboxForMac/NSDictionary+URLArguments (~> 2.1)
    - GTMSessionFetcher/Core (~> 1.1)
  - FirebaseCore (4.0.12):
    - GoogleToolboxForMac/NSData+zlib (~> 2.1)
  - FirebaseInstanceID (2.0.7)
  - FirebaseMessaging (2.0.7):
    - FirebaseAnalytics (~> 4.0)
    - FirebaseCore (~> 4.0)
    - FirebaseInstanceID (~> 2.0)
    - GoogleToolboxForMac/Logger (~> 2.1)
    - Protobuf (~> 3.1)
  - GoogleToolboxForMac/DebugUtils (2.1.3):
    - GoogleToolboxForMac/Defines (= 2.1.3)
  - GoogleToolboxForMac/Defines (2.1.3)
  - GoogleToolboxForMac/Logger (2.1.3):
    - GoogleToolboxForMac/Defines (= 2.1.3)
  - GoogleToolboxForMac/NSData+zlib (2.1.3):
    - GoogleToolboxForMac/Defines (= 2.1.3)
  - GoogleToolboxForMac/NSDictionary+URLArguments (2.1.3):
    - GoogleToolboxForMac/DebugUtils (= 2.1.3)
    - GoogleToolboxForMac/Defines (= 2.1.3)
    - GoogleToolboxForMac/NSString+URLArguments (= 2.1.3)
  - GoogleToolboxForMac/NSString+URLArguments (2.1.3)
  - GTMSessionFetcher/Core (1.1.12)
  - nanopb (0.3.8):
    - nanopb/decode (= 0.3.8)
    - nanopb/encode (= 0.3.8)
  - nanopb/decode (0.3.8)
  - nanopb/encode (0.3.8)
  - Protobuf (3.5.0)
  - QBImagePickerController (3.4.0)
  - RSKImageCropper (2.0.0)

DEPENDENCIES:
  - Firebase/Auth
  - Firebase/Core
  - Firebase/Messaging
  - QBImagePickerController
  - RSKImageCropper

SPEC CHECKSUMS:
  Firebase: dbfb98ccec2dcfcd21ab9cc1b4981a3f3c8c5e26
  FirebaseAnalytics: 5b02a63ead2c3f0259cfc7f15e053e440587ecf8
  FirebaseAuth: cdeee95b528958dbb7dcf220ad0fb804d3a284b0
  FirebaseCore: 6cf108b63997bc08c04a1ffa55a3ac0d71a59ffc
  FirebaseInstanceID: 148c25c986c8699e67304b114e365713dce467f2
  FirebaseMessaging: 1a11d1c0a9ed9b3f75a0685bb0ae5932e1062f5f
  GoogleToolboxForMac: 2501e2ad72a52eb3dfe7bd9aee7dad11b858bd20
  GTMSessionFetcher: ebaa1f79a5366922c1735f1566901f50beba23b7
  nanopb: 5601e6bca2dbf1ed831b519092ec110f66982ca3
  Protobuf: 8a9838fba8dae3389230e1b7f8c104aa32389c03
  QBImagePickerController: d54cf93db6decf26baf6ed3472f336ef35cae022
  RSKImageCropper: d9a1acbc0600bf8decc8f0d21895872c99a9e4cf

PODFILE CHECKSUM: 6a2aacaf194fa5515d1ce69b74adbfd19705c44a

COCOAPODS: 1.3.1

brunolemos avatar Dec 12 '17 17:12 brunolemos

@chrisbianca If I rename RNFirebaseMessaging to RNFIRMessaging it works!

brunolemos avatar Dec 12 '17 17:12 brunolemos

Hi @hama,

These are the changes I made to get things working.

  1. Run react-native link react-native-firebase
  2. Ensure [FIRApp configure]; comes right after NSURL *jsCodeLocation; as mentioned here (previously this was placed further down the file and was being called too late).

joegoodall1 avatar Dec 12 '17 18:12 joegoodall1

Hi! I had the same problem. This is how I fixed: I'm using react-native link not pods.

In Xcode:

  1. Libraries/RNFirebase -> Build Phases:
  • add to headers RNFirebaseMessaging.h
  1. Libraries/RNFirebase -> Build Settings:
  • In packaging section set Public Headers Folder Path debug and release to default (/usr/local/include)
  1. Change #import "RNFirebaseMessaging.h" to #import <RNFirebase/RNFirebaseMessaging.h>

  2. Clean, Build

projekt86 avatar Dec 16 '17 13:12 projekt86

@projekt86 how can I add the RNFirebaseMessaging.h in the headers Libraries/RNFirebase -> Build Phases? I can't find it.

drailanjohngss avatar Jan 22 '18 10:01 drailanjohngss

I solved this one by putting $(SRCROOT)/../node_modules/react-native-firebase/ios/RNFirebase/messaging in to the Header Search paths

drailanjohngss avatar Jan 23 '18 04:01 drailanjohngss

Just making "$(SRCROOT)/../node_modules/react-native-firebase/ios/RNFirebase" recursive worked for me

JF-13 avatar May 10 '18 19:05 JF-13

@JF-13 has the right answer as it will ensure each module beyond messaging will work. Thanks fam.

GentryRiggen avatar Jul 14 '18 16:07 GentryRiggen

If you're using Pods, there's no need to import RNFirebaseMessaging.h or add anything in AppDelegate.m.

ghost avatar Aug 28 '18 13:08 ghost

@calintamasyopeso that's not true. If those files are not imported you get these errors:

▸ Compiling AppDelegate.m

❌  /Users/gianfranco/temp/dec03/ios/dec03/AppDelegate.m:27:4: use of undeclared identifier 'RNFirebaseNotifications'

  [RNFirebaseNotifications configure]; // for react-native-firebase w/ Notifications
   ^



❌  /Users/gianfranco/temp/dec03/ios/dec03/AppDelegate.m:51:5: use of undeclared identifier 'RNFirebaseNotifications'

  [[RNFirebaseNotifications instance] didReceiveLocalNotification:notification];
    ^



❌  /Users/gianfranco/temp/dec03/ios/dec03/AppDelegate.m:56:5: use of undeclared identifier 'RNFirebaseNotifications'

  [[RNFirebaseNotifications instance] didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
    ^


** BUILD FAILED **

new RN 0.57.7 project (with react-native init)

gianpaj avatar Dec 04 '18 12:12 gianpaj

headers search, select "recursive".

marcioaso avatar Jan 28 '20 23:01 marcioaso