React-native-code-push: Can't build: 'React/RCTEventEmitter.h' file not found

Created on 28 May 2019  路  8Comments  路  Source: microsoft/react-native-code-push

Steps to Reproduce

  1. Start with an ejected create react native app project
  2. Install App Center libraries (sets up CocoaPods)
  3. Install React Native Code Push

Expected Behavior

Successful build when running react-native run-ios

Actual Behavior

[project directory]/node_modules/react-native-code-push/ios/CodePush/CodePush.h:6:9: fatal error: 'React/RCTEventEmitter.h' file not found
#import "React/RCTEventEmitter.h"   // Required when used as a Pod in a Swift project
        ^~~~~~~~~~~~~~~~~~~~~~~~~


error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening [project name].xcworkspace

** BUILD FAILED **

Reproducible Demo

Cannot reproduce using these steps as App Center needs to be installed before CodePush, which then makes CodePush want to use pods.

I can send a copy of the project to someone from Microsoft, but cannot post it in a publicly accessible location. Please give me details and I'd be happy to send the project to you to help debug.

Environment

  • react-native-code-push version: 5.6.0
  • react-native version: 0.59.8
  • iOS/Android/Windows version: iOS 12.2
  • Does this reproduce on a debug build or release build? Can't build.
  • Does this reproduce on a simulator, or only on a physical device? Simulator
bug no-response

Most helpful comment

Actually I've managed to fix this in the meantime.

The problem is that the react-native-code-push pod brings in React v11 by default. What we actually want to do is get pods to recognise the version of React Native that we have in node_modules, which is much newer than v11.

So here's the resulting podfile that fixed the build for me:

target 'MyProject' do
  # Pods for MyProject
  platform :ios, '9.0'

  # React Native Pods
  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    'CxxBridge',
    'DevSupport',
    'RCTText',
    'RCTNetwork',
    'RCTWebSocket',
    'RCTAnimation',
  ]
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

  # Additional project specific pods
  pod 'AppCenter/Crashes', '~> 2.0.1'
  pod 'AppCenter/Analytics', '~> 2.0.1'
  pod 'AppCenterReactNativeShared', '~> 2.0.0'
  pod 'CodePush', :path => '../node_modules/react-native-code-push'

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

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

end

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

  # Pods for MyProject-tvOS

  target 'MyProject-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end

end

Once ios/Podfile looked like the above, I ran react-native link which I assume ran pod install, then the build worked.

It'd be awesome if CodePush could see that this was the case and warn the user about it, or add a link to this page from the docs: https://facebook.github.io/react-native/docs/integration-with-existing-apps#configuring-cocoapods-dependencies

I had missed it because I wasn't integrating with an existing app, but it turns out this is more a guide of how to set up Cocoapods on an RN project in general.

All 8 comments

Hi @thekevinbrown,
Thanks for reporting!

Yeah, could you please provide your dummy project with reproducing issue and reprosteps? I would like to debug it.
If you would not like to share it here, you can send it to my email: [email protected]

Thanks @alexandergoncharov, project sent.

Actually I've managed to fix this in the meantime.

The problem is that the react-native-code-push pod brings in React v11 by default. What we actually want to do is get pods to recognise the version of React Native that we have in node_modules, which is much newer than v11.

So here's the resulting podfile that fixed the build for me:

target 'MyProject' do
  # Pods for MyProject
  platform :ios, '9.0'

  # React Native Pods
  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    'CxxBridge',
    'DevSupport',
    'RCTText',
    'RCTNetwork',
    'RCTWebSocket',
    'RCTAnimation',
  ]
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

  # Additional project specific pods
  pod 'AppCenter/Crashes', '~> 2.0.1'
  pod 'AppCenter/Analytics', '~> 2.0.1'
  pod 'AppCenterReactNativeShared', '~> 2.0.0'
  pod 'CodePush', :path => '../node_modules/react-native-code-push'

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

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

end

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

  # Pods for MyProject-tvOS

  target 'MyProject-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end

end

Once ios/Podfile looked like the above, I ran react-native link which I assume ran pod install, then the build worked.

It'd be awesome if CodePush could see that this was the case and warn the user about it, or add a link to this page from the docs: https://facebook.github.io/react-native/docs/integration-with-existing-apps#configuring-cocoapods-dependencies

I had missed it because I wasn't integrating with an existing app, but it turns out this is more a guide of how to set up Cocoapods on an RN project in general.

I have same question too, but I got this question from react-native link, my react-native version is 0.58.4, react-native-code-push version is 5.4.2,

Hi @thekevinbrown,
Sorry for the delay.

Could you please provide the title of the email as I can't find it?

Also, could you please clarify you got this issue when you used pods from setup docs from here https://github.com/microsoft/react-native-code-push/blob/master/docs/setup-ios.md#plugin-installation-ios---cocoapods?

Hi @gh7800 ,
Thanks for reporting!

Could you please provide some reprosteps or dome dummy project with reproducing issue and reprosteps? I would like to debug it.

Hi @thekevinbrown and @gh7800,

I'm going to close this issue for now as I haven't heard from you in a while, unfortunately.
Please feel free to reopen this issue if you have any questions or provide some dummy project.

Thanks,
Alexander

'React/RCTEventEmitter.h' file not found in React native /pods/Development Pods/CodePush.h

Was this page helpful?
0 / 5 - 0 ratings

Related issues

quanzaiyu picture quanzaiyu  路  3Comments

ACCTFORGH picture ACCTFORGH  路  3Comments

panarasi picture panarasi  路  4Comments

sergey-akhalkov picture sergey-akhalkov  路  4Comments

ninjz picture ninjz  路  4Comments