'RCTEventEmitter.h' file not found while building iOS swift based | React Pod deprecated
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:

Expected result:
- Successful build
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
Got it working!
For anyone reading this, these are the steps I took:
- Do NOT use CocoaPods for
react-native-sentry - Follow the standard install steps:
a)
yarn react-native-sentryb)react-native link react-native-sentry - If your Podfile was modified by the setup script, remove any reference of ReactNativeSentry
- Open Xcode and drag
node_modules/react-native-sentry/ios/RNSentry.xcodeprojinto your project's Libraries directory - Open your project's "Linked Frameworks and Libraries" and add
libRNSentry.a
Hope that helps!
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..
@Jflima92 since you're using Swift, you likely have to add the import to your bridging header first.
@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!!
@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.
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 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.
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.
@amsul this is the only thing that finally fixed this header files issue both locally and on our CI. thank you!
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 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.
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.
Same issue react-native-sentry: ^0.37.1, react-native: 0.51.0
i try all way above, it's still error =))))
@amsul You saved my life :D
@amsul's answer should be in Sentry's documentation.
@amsul you're the best!
good solution
@amsul Thanks, this works. Btw, the lib that we should add is libRNSentry.a