evollu / react-native-fcm

react native module for firebase cloud messaging and local notification
MIT License
1.73k stars 681 forks source link

"_OBJC_CLASS_$_RNFIRMessaging", referenced from: objc-class-ref in AppDelegate.o ld: symbol(s) not found for architecture x86_64 #1023

Closed klausbreyer closed 5 years ago

klausbreyer commented 5 years ago
  1. What version of RN and react-native-fcm are you running? RN 0.56 fcm 16.1

  2. What device are you using? (e.g iOS9 emulator, Android 6 device)? Simulator

  3. Is your app running in foreground, background or not running? not running.

I am really clueless how to start with react native fcm.

Ld /Users/kb1/Library/Developer/Xcode/DerivedData/rsvptrainingapp-bzeukoujtynelbfdnnsecrvvrvhh/Build/Products/Debug-iphonesimulator/rsvptrainingapp.app/rsvptrainingapp normal x86_64
    cd /Users/kb1/versioned/rsvptrainingapp/ios
    export IPHONEOS_DEPLOYMENT_TARGET=9.0
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk -L/Users/kb1/Library/Developer/Xcode/DerivedData/rsvptrainingapp-bzeukoujtynelbfdnnsecrvvrvhh/Build/Products/Debug-iphonesimulator -L/Users/kb1/Library/Developer/Xcode/DerivedData/rsvptrainingapp-bzeukoujtynelbfdnnsecrvvrvhh/Build/Products/Debug-iphonesimulator/BoringSSL -L/Users/kb1/Library/Developer/Xcode/DerivedData/rsvptrainingapp-bzeukoujtynelbfdnnsecrvvrvhh/Build/Products/Debug-iphonesimulator/FirebaseCore -L/Users/kb1/Library/Developer/Xcode/DerivedData/rsvptrainingapp-bzeukoujtynelbfdnnsecrvvrvhh/Build/Products/Debug-iphonesimulator/FirebaseFirestore -L/Users/kb1/Library/Developer/Xcode/DerivedData/rsvptrainingapp-bzeukoujtynelbfdnnsecrvvrvhh/Build/Products/Debug-iphonesimulator/FirebaseMessaging -L/Users/kb1/Library/Developer/Xcode/DerivedData/rsvptrainingapp-bzeukoujtynelbfdnnsecrvvrvhh/Build/Products/Debug-iphonesimulator/GoogleToolboxForMac -L/Users/kb1/Library/Developer/Xcode/DerivedData/rsvptrainingapp-bzeukoujtynelbfdnnsecrvvrvhh/Build/Products/Debug-iphonesimulator/Protobuf -L/Users/kb1/Library/Developer/Xcode/DerivedData/rsvptrainingapp-bzeukoujtynelbfdnnsecrvvrvhh/Build/Products/Debug-iphonesimulator/gRPC -L/Users/kb1/Library/Developer/Xcode/DerivedData/rsvptrainingapp-bzeukoujtynelbfdnnsecrvvrvhh/Build/Products/Debug-iphonesimulator/gRPC-Core -L/Users/kb1/Library/Developer/Xcode/DerivedData/rsvptrainingapp-bzeukoujtynelbfdnnsecrvvrvhh/Build/Products/Debug-iphonesimulator/gRPC-ProtoRPC -L/Users/kb1/Library/Developer/Xcode/DerivedData/rsvptrainingapp-bzeukoujtynelbfdnnsecrvvrvhh/Build/Products/Debug-iphonesimulator/gRPC-RxLibrary -L/Users/kb1/Library/Developer/Xcode/DerivedData/rsvptrainingapp-bzeukoujtynelbfdnnsecrvvrvhh/Build/Products/Debug-iphonesimulator/leveldb-library -L/Users/kb1/Library/Developer/Xcode/DerivedData/rsvptrainingapp-bzeukoujtynelbfdnnsecrvvrvhh/Build/Products/Debug-iphonesimulator/nanopb -F/Users/kb1/Library/Developer/Xcode/DerivedData/rsvptrainingapp-bzeukoujtynelbfdnnsecrvvrvhh/Build/Products/Debug-iphonesimulator -F/Users/kb1/versioned/rsvptrainingapp/ios/Pods/FirebaseAnalytics/Frameworks -F/Users/kb1/versioned/rsvptrainingapp/ios/Pods/FirebaseInstanceID/Frameworks -filelist /Users/kb1/Library/Developer/Xcode/DerivedData/rsvptrainingapp-bzeukoujtynelbfdnnsecrvvrvhh/Build/Intermediates.noindex/rsvptrainingapp.build/Debug-iphonesimulator/rsvptrainingapp.build/Objects-normal/x86_64/rsvptrainingapp.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -mios-simulator-version-min=9.0 -Xlinker -object_path_lto -Xlinker /Users/kb1/Library/Developer/Xcode/DerivedData/rsvptrainingapp-bzeukoujtynelbfdnnsecrvvrvhh/Build/Intermediates.noindex/rsvptrainingapp.build/Debug-iphonesimulator/rsvptrainingapp.build/Objects-normal/x86_64/rsvptrainingapp_lto.o -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -ObjC -lBoringSSL -lFirebaseCore -lFirebaseFirestore -lFirebaseMessaging -lGoogleToolboxForMac -lProtobuf -lc++ -lgRPC -lgRPC-Core -lgRPC-ProtoRPC -lgRPC-RxLibrary -lleveldb-library -lnanopb -lsqlite3 -lz -framework FirebaseAnalytics -framework FirebaseCoreDiagnostics -framework FirebaseInstanceID -framework FirebaseNanoPB -framework Foundation -framework MobileCoreServices -framework Security -framework StoreKit -framework SystemConfiguration -ObjC -lc++ -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __entitlements -Xlinker /Users/kb1/Library/Developer/Xcode/DerivedData/rsvptrainingapp-bzeukoujtynelbfdnnsecrvvrvhh/Build/Intermediates.noindex/rsvptrainingapp.build/Debug-iphonesimulator/rsvptrainingapp.build/rsvptrainingapp.app-Simulated.xcent /Users/kb1/Library/Developer/Xcode/DerivedData/rsvptrainingapp-bzeukoujtynelbfdnnsecrvvrvhh/Build/Products/Debug-iphonesimulator/libRCTBlob.a /Users/kb1/Library/Developer/Xcode/DerivedData/rsvptrainingapp-bzeukoujtynelbfdnnsecrvvrvhh/Build/Products/Debug-iphonesimulator/libRCTAnimation.a /Users/kb1/Library/Developer/Xcode/DerivedData/rsvptrainingapp-bzeukoujtynelbfdnnsecrvvrvhh/Build/Products/Debug-iphonesimulator/libReact.a /Users/kb1/Library/Developer/Xcode/DerivedData/rsvptrainingapp-bzeukoujtynelbfdnnsecrvvrvhh/Build/Products/Debug-iphonesimulator/libRCTAnimation.a /Users/kb1/Library/Developer/Xcode/DerivedData/rsvptrainingapp-bzeukoujtynelbfdnnsecrvvrvhh/Build/Products/Debug-iphonesimulator/libRCTActionSheet.a /Users/kb1/Library/Developer/Xcode/DerivedData/rsvptrainingapp-bzeukoujtynelbfdnnsecrvvrvhh/Build/Products/Debug-iphonesimulator/libRCTGeolocation.a /Users/kb1/Library/Developer/Xcode/DerivedData/rsvptrainingapp-bzeukoujtynelbfdnnsecrvvrvhh/Build/Products/Debug-iphonesimulator/libRCTImage.a /Users/kb1/Library/Developer/Xcode/DerivedData/rsvptrainingapp-bzeukoujtynelbfdnnsecrvvrvhh/Build/Products/Debug-iphonesimulator/libRCTLinking.a /Users/kb1/Library/Developer/Xcode/DerivedData/rsvptrainingapp-bzeukoujtynelbfdnnsecrvvrvhh/Build/Products/Debug-iphonesimulator/libRCTNetwork.a /Users/kb1/Library/Developer/Xcode/DerivedData/rsvptrainingapp-bzeukoujtynelbfdnnsecrvvrvhh/Build/Products/Debug-iphonesimulator/libRCTSettings.a /Users/kb1/Library/Developer/Xcode/DerivedData/rsvptrainingapp-bzeukoujtynelbfdnnsecrvvrvhh/Build/Products/Debug-iphonesimulator/libRCTText.a /Users/kb1/Library/Developer/Xcode/DerivedData/rsvptrainingapp-bzeukoujtynelbfdnnsecrvvrvhh/Build/Products/Debug-iphonesimulator/libRCTVibration.a /Users/kb1/Library/Developer/Xcode/DerivedData/rsvptrainingapp-bzeukoujtynelbfdnnsecrvvrvhh/Build/Products/Debug-iphonesimulator/libRCTWebSocket.a -lRNFirebase -lPods-rsvptrainingapp -Xlinker -dependency_info -Xlinker /Users/kb1/Library/Developer/Xcode/DerivedData/rsvptrainingapp-bzeukoujtynelbfdnnsecrvvrvhh/Build/Intermediates.noindex/rsvptrainingapp.build/Debug-iphonesimulator/rsvptrainingapp.build/Objects-normal/x86_64/rsvptrainingapp_dependency_info.dat -o /Users/kb1/Library/Developer/Xcode/DerivedData/rsvptrainingapp-bzeukoujtynelbfdnnsecrvvrvhh/Build/Products/Debug-iphonesimulator/rsvptrainingapp.app/rsvptrainingapp

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_RNFIRMessaging", referenced from:
      objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Pods are there.

➜  ios git:(master) pod install
Analyzing dependencies
Fetching podspec for `react-native-fcm` from `../node_modules/react-native-fcm`
Downloading dependencies
Using BoringSSL (10.0.6)
Using Firebase (5.3.0)
Using FirebaseAnalytics (5.0.1)
Using FirebaseCore (5.0.4)
Using FirebaseFirestore (0.12.4)
Using FirebaseInstanceID (3.1.1)
Using FirebaseMessaging (3.0.2)
Using GoogleToolboxForMac (2.1.4)
Using Protobuf (3.6.1)
Installing React (0.11.0)
Using gRPC (1.14.1)
Using gRPC-Core (1.14.1)
Using gRPC-ProtoRPC (1.14.1)
Using gRPC-RxLibrary (1.14.1)
Using leveldb-library (1.20)
Using nanopb (0.3.8)
Installing react-native-fcm (16.1.0)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There are 4 dependencies from the Podfile and 17 total pods installed.

[!] Automatically assigning platform `ios` with version `9.0` on target `rsvptrainingapp` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.

[!] The `rsvptrainingapp-tvOSTests [Debug]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods-rsvptrainingapp-tvOSTests/Pods-rsvptrainingapp-tvOSTests.debug.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

[!] The `rsvptrainingapp-tvOSTests [Release]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods-rsvptrainingapp-tvOSTests/Pods-rsvptrainingapp-tvOSTests.release.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

[!] The `rsvptrainingappTests [Debug]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods-rsvptrainingappTests/Pods-rsvptrainingappTests.debug.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

[!] The `rsvptrainingappTests [Release]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods-rsvptrainingappTests/Pods-rsvptrainingappTests.release.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

[!] React has been deprecated

Everything is linked

➜  rsvptrainingapp git:(master) ✗ react-native link
Scanning folders for symlinks in /Users/kb1/versioned/rsvptrainingapp/node_modules (13ms)
rnpm-install info Platform 'ios' module react-native-fcm is already linked
rnpm-install info Platform 'android' module react-native-fcm is already linked
rnpm-install info Platform 'ios' module react-native-firebase is already linked
rnpm-install info Platform 'android' module react-native-firebase is already linked

I am really clueless what to try next.

This is my 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 <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import "RNFirebaseNotifications.h"
#import <Firebase.h>
#import "RNFIRMessaging.h"

@implementation AppDelegate

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

  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];

  RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
                                                      moduleName:@"rsvptrainingapp"
                                               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];

  // add before return YES;
  [FIRApp configure];
  [[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];

  return YES;
}

// add before @end
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler
{
  [RNFIRMessaging willPresentNotification:notification withCompletionHandler:completionHandler];
}

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

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{
  [RNFIRMessaging didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}
@end
tunm1228 commented 5 years ago

I am having the following issue

evollu commented 5 years ago

try remove DerivedData folder for a clean build since you are using rnpm, do you see RNFIRMessaging under Library in Project Navigator?

klausbreyer commented 5 years ago

@evollu at first i did not see a RNFIRMessaging under library.

Then I added it via drag and drop and linked it manually: image

I added it to all 4 targets (iphone + tests + tvos + tests - recursive.

also cleaned Xcode, deleted DerivedData, restarted xcode and compiled again.

sidenote:

though I am a cocoa pods user, I linked via cli:

Scanning folders for symlinks in /Users/kb1/versioned/rsvptrainingapp/node_modules (14ms)
rnpm-install info Platform 'ios' module react-native-fcm is already linked
rnpm-install info Platform 'android' module react-native-fcm is already linked
rnpm-install info Platform 'ios' module react-native-firebase is already linked
rnpm-install info Platform 'android' module react-native-firebase is already linked
klausbreyer commented 5 years ago

omg tuns out it works, after I followed closely your readme instructions.

I am very sorry about the circumstances. in fact, this is one of the most detailed and best explanations for build + link that i have run into in 3 years react native.

i just crossed the rn firebase tutorial and hadn't read your own readme.