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

'RCTEventEmitter.h' file not found while building iOS swift based | React Pod deprecated

Open jfmlima opened this issue 8 years ago • 23 comments

OS:

  • [ ] Windows
  • [x] MacOS
  • [ ] Linux

Platform:

  • [x] iOS
  • [ ] Android

Output of node -v && npm -v && npm ls --prod --depth=0

v8.9.0
5.5.1

├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]

Config:

Sentry.config('https://[email protected]/...', {
....
}).install()

I have following issue:

I'm trying to setup sentry in my react-native project without success.

I've already put up an issue in sentry-wizard regarding users that use swift instead of objC because the setup is not done properly when using swift.

But basically, after linking everything and manually add the excerpt of code to AppDelegate.swift I do pod install to get the Sentry libs, but apparently React Pod also comes as a dependency, despite being deprecated. I'm not sure if that's causing the issue, but after all these steps, while build the project I always get 'RCTEventEmitter.h' file not found in RNSentryEventEmitter.h even though I can navigate to the RCTEventEmitter interface file.

Any help would be appreciated. Thanks in advance.

Steps to reproduce:

  • React Native project using swift for iOS
  • yarn add react-native-sentry
  • react-native link react-native-sentry
  • pod install
  • Manually add missing code to AppDelegate.swift
  • Build Project

Actual result: image

Expected result:

  • Successful build

jfmlima avatar Feb 01 '18 16:02 jfmlima

I can confirm that I'm having this exact same issue. And I'm not using Swift, so I'm pretty sure it has nothing to do with that.

Not sure if downgrading will help - but gonna give it a shot

EDIT: Downgrading to 0.32.1 did not help

amsul avatar Feb 01 '18 17:02 amsul

Got it working!

For anyone reading this, these are the steps I took:

  1. Do NOT use CocoaPods for react-native-sentry
  2. Follow the standard install steps: a) yarn react-native-sentry b) react-native link react-native-sentry
  3. If your Podfile was modified by the setup script, remove any reference of ReactNativeSentry
  4. Open Xcode and drag node_modules/react-native-sentry/ios/RNSentry.xcodeproj into your project's Libraries directory
  5. Open your project's "Linked Frameworks and Libraries" and add libRNSentry.a

Hope that helps!

amsul avatar Feb 01 '18 18:02 amsul

Hey @amsul thanks for the reply! I'll give it a shot and see it it works! EDIT: I can't seem to add the needed code to my AppDelegate.swift because it never finds the RNSEntry module..

jfmlima avatar Feb 01 '18 18:02 jfmlima

@Jflima92 since you're using Swift, you likely have to add the import to your bridging header first.

amsul avatar Feb 01 '18 19:02 amsul

@amsul I've done that after adding the react-native-sentry ios folder to the headers search path with recursive mode, but still no luck. Am I missing something? 😞

EDIT: I was unnecessarily importing RNSentry in .swift, there's no need to import, now it works!!

jfmlima avatar Feb 02 '18 08:02 jfmlima

@amsul Thanks so much for your post. Was struggling to get Sentry installed and built without errors and NOT using CocoaPods was the way to go.

ctoppel avatar Feb 15 '18 23:02 ctoppel

So am I correct to conclude that the official install instructions for react native on iOS are wrong?

Just trying to understand if this is a workaround for some rare issue, or if the documentation is outdated.

askielboe avatar Apr 17 '18 07:04 askielboe

@askielboe not sure if it's "wrong" per se..I've seen other RN packages suggest similar steps of adding a dependency to the Podfile that points to node_modules. But I've never been able to get my builds to fully work in those cases.

However, this setup seems to always work.

amsul avatar Apr 17 '18 16:04 amsul

Yep, that's also my experience. Even for packages that very explicitly demands that I use cocoapods, I can never get it to work properly. But manually linking, as in this case, always seems to work.

Guess I was just wondering what the reason was to add the podspec when it seems not to work in a lot of cases. I like cocoapods for native development, and it would indeed be nice if it worked for RN native dependencies as well.

askielboe avatar Apr 18 '18 07:04 askielboe

@amsul this is the only thing that finally fixed this header files issue both locally and on our CI. thank you!

sheminusminus avatar May 07 '18 16:05 sheminusminus

For me, this commit was the cause of the error: https://github.com/getsentry/react-native-sentry/commit/320651c23144664fb193c34a484a9fbee492dee9#diff-d8cd0abcb714ce13da6a6f2645e214af

After reverting that, the build finishes without problems. As a workaround until it's fixed or explained, I've added an npm post install script that reverts the commit.

if [ -f ./node_modules/react-native-sentry/SentryReactNative.podspec ]
then
  if ! grep "s.dependency 'React'" ./node_modules/react-native-sentry/SentryReactNative.podspec
  then
      sed -i.bak \
         $'s#s.dependency \'Sentry\'#s.dependency \'React\'\\\n  s.dependency \'Sentry\'#g' \
         ./node_modules/react-native-sentry/SentryReactNative.podspec
  fi
fi

(no sed-expert, but it seems to work...)

othorin avatar May 15 '18 12:05 othorin

@othorin Do you still have to error when using CocoaPods 1.4.0 as described here: https://github.com/getsentry/react-native-sentry/issues/395#issuecomment-388215879

TBH I don't really had time to wrap my head around this issue if the error lies on the CocoaPods or react-native side. Both seem to have downsides but people seem to have more trouble now than before, I've asked the contributor to elaborate more on this, otherwise I will revert this back so React is in the podspec.

HazAT avatar May 16 '18 10:05 HazAT

Hey, so I reverted the change, React is back in the podspec. Version 0.37.0 is on its way, sorry for the inconvenience this has caused.

HazAT avatar May 17 '18 07:05 HazAT

Same issue react-native-sentry: ^0.37.1, react-native: 0.51.0

pitchourou avatar Jun 10 '18 15:06 pitchourou

i try all way above, it's still error =))))

hoangvuanhdevelopervn avatar Jul 03 '18 06:07 hoangvuanhdevelopervn

@amsul You saved my life :D

ChiAnTai avatar Aug 06 '18 07:08 ChiAnTai

@amsul's answer should be in Sentry's documentation.

DimiTech avatar Aug 24 '18 09:08 DimiTech

@amsul you're the best!

erwinjulius avatar Sep 13 '18 13:09 erwinjulius

good solution

kenjiUT avatar Oct 26 '18 04:10 kenjiUT

@amsul Thanks, this works. Btw, the lib that we should add is libRNSentry.a

onmyway133 avatar Oct 26 '18 12:10 onmyway133