evollu / react-native-fcm

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

Xcode Build error: 'React/RCTBridge.h' file not found #766

Open MelissaWeng opened 6 years ago

MelissaWeng commented 6 years ago

react-native: 0.49.3 "react-native-fcm": "^11.3.1" ejected to ExpoKit

I followed the instruction to do the configurations for IOS, got this error: "'React/RCTBridge.h' file not found" at the line #import <React/RCTBridge.h> (in RCTEventEmitter.h file) when build in Xcode.

Any solutions for that?

evollu commented 6 years ago

clear derived data? usually it happens when the build is reusing some old derived data

zeddz92 commented 6 years ago

I did delete the derived data and still get the same error, do i need to move the React pod to ios/Frameworks?

evollu commented 6 years ago

I use ios/Frameworks for both react and fcm library. check the manual linking

deno028 commented 6 years ago

This issue took me a lot of time. It seems to be a problem of Cocoapods(1.4.0) and React Native 0.5x.x. I solved it by removed React and all the package links in Podfile looks like:

pod 'react-native-fcm', :path => '../node_modules/react-native-fcm'

 # pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'

Then manual link these removing packages.

Note: Remember to remove parralled build and prepend React to the build list in edit Build Target.

CapitanRedBeard commented 6 years ago

@Deno028 Can you elaborate exactly what you have to do to remove React and all package links in the Podfile and then manual linking the removed packaged, seems I've manually linked packages before but I'm confused where it's all suppose to go within the pod workspace project and how that plays nicely

deno028 commented 6 years ago

@CapitanRedBeard Please dont run react-native link. It may break your IOS project link.

1. Remove React in pod. This is my Podfile:

def pod_packages
  pod 'SwiftyJSON', '3.1.4'
  pod 'Charts', '3.0.3'
  pod 'Firebase/Messaging'
  pod 'RSKImageCropper', '1.6.1'
  pod 'QBImagePickerController', '3.4.0'
  pod 'Fabric'
  pod 'Crashlytics'
end

abstract_target 'All' do
  target 'MyXXXProject' do
     pod_packages
  **###### note these packages was gen after run react-native link. Please dont run it. If you run you should comment it out by hand.**
     # pod 'react-native-config', :path => '../node_modules/react-native-config'
     # pod 'react-native-fcm', :path => '../node_modules/react-native-fcm'
     # pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
     # pod 'react-native-camera', path: '../node_modules/react-native-camera'

     target 'MyXXXProjectTests' do
       inherit! :search_paths
       # Pods for testing
     end
  end
end

post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['SWIFT_VERSION'] = '3.0'
        end
    end
end

2. To manual link: you just drag and drop the package from node_module folder like the official guide.

This is my IOS project structure. ios-proj

elanpang commented 5 years ago

@Deno028 You are right, for me I generated iOS project by eject or init command, so I don't have to manual link react libs, but I also must remove React Section in podfile even the official doc ask you to add them in pod, if add them I will can't run my project.

I think only old native project need to add react section to podfile, if your project is generated by Rn runtime, it already include linked Rn libs. If you add rn section to podfile, it will be duplicated, I real hope FB could offer more details workflow with cocoapod and update the offical doc.