Closed ghost closed 7 years ago
There should be something like this on top of the AppDelegate.h
file:
#if __has_include(<React/RNSentry.h>)
#import <React/RNSentry.h> // This is used for versions of react >= 0.40
#else
#import "RNSentry.h" // This is used for versions of react < 0.40
#endif
https://docs.sentry.io/clients/react-native/manual-setup/#appdelegate
@HazAT hi there,
i've added those code on the top of the AppDelegate.h
file,
but i get some new errors in the RCTRootView.h
file, like this:
Redefinition of 'RCTRootViewSizeFlexibility'
Redefinition of enumerator 'RCTRootViewSizeFlexibilityNone'
Redefinition of enumerator 'RCTRootViewSizeFlexibilityWidth'
...
how do i solve this problem ? thx! btw, i'm using react native of v 0.44.0, is that cause this issue? i used v 0.39 before and it goes well.
It seems like something went really wrong when setting up your react-native project. Did you follow this guide?: https://facebook.github.io/react-native/docs/getting-started.html#installing-dependencies Since this error indicates that react-native has been imported twice. Also, you can check out the example project: https://github.com/getsentry/examples/tree/master/react-native https://github.com/getsentry/examples/blob/master/react-native/AwesomeProject/ios/AwesomeProject/AppDelegate.m
@Tomatoo @KkkkKernc Can you paste your output of
npm ls --prod --depth=0
please?
thans, it is our problems and we have solved it.
I ran just these two steps on my codebase -
npm i --save react-native-sentry
react-native link react-native-sentry
and I am getting this 'undeclared identifier' error when building for iOS.To confirm what @Tomatoo said, the link step doesn't add [these](//#import <React/RNSentry.h>) import statements to AppDelegate
. Manually adding those lines leads to the errors that @KkkkKernc talks about here.
@Tomatoo what was the solution in your case?
@HazAT the output of npm ls --prod --depth=0
for me -
├── babel-plugin-transform-remove-console@6.8.5
├── babel-preset-react-native-stage-0@1.0.1
├── color@1.0.3
├── lodash.debounce@4.0.8
├── moment@2.18.1
├── moment-timezone@0.5.13
├── native-base@0.5.20
├── node-emoji@1.8.1
├── UNMET PEER DEPENDENCY react@16.0.0-alpha.6
├── react-native@0.44.3
├── react-native-action-button@2.0.20 (git+https://github.com/cvquant/react-native-action-button.git#2e56d8a88c82be1d1f062075c85ad5afeaf2213a)
├── react-native-android-statusbar@0.1.3
├── react-native-appstate-listener@1.0.0
├── react-native-blur@3.1.2
├── react-native-chart-android@1.0.3 (git+https://github.com/cvquant/react-native-chart-android.git#a3df9c2cfd226c8e507ff1277ba540cd0a67fc96)
├── react-native-code-push@2.0.3-beta
├── react-native-cookies@3.1.0
├── react-native-deprecated-custom-components@0.1.0
├── react-native-extended-stylesheet@0.3.2
├── react-native-fabric@0.4.1
├── react-native-fbsdk@0.6.1
├── react-native-gifted-chat@0.1.3 (git+https://github.com/cvquant/react-native-gifted-chat.git#c5ec75bb22d00c5b634c411a9beb1e00a9cfcc43)
├── react-native-google-signin@0.10.0 (git+https://github.com/prithsharma/react-native-google-signin.git#fcf945cae2ae41b7272afcf51d54232c709713b2)
├── react-native-instabug@0.2.8 (git+https://github.com/cvquant/react-native-instabug.git#f34253704b0b9d21fa5b237104aa8e88f4159f22)
├── react-native-interactable@0.0.9
├── react-native-intercom@5.9.0
├── react-native-ios-charts@0.3.0 (git+https://github.com/cvquant/react-native-ios-charts.git#51a0a2289022cd0cf6ffdba0d9bb2d7100aa41d1)
├── react-native-keyboard-aware-scroll-view@0.2.9
├── react-native-keyboard-spacer@0.3.1
├── react-native-linear-gradient@2.3.0
├── react-native-material-design@0.3.8 (git+https://github.com/cvquant/react-native-material-design.git#25810fc29b9e57964317338a9fa65ce0f816d981)
├── react-native-modal@2.5.0
├── react-native-modal-picker@0.0.16 (git+https://github.com/cvquant/react-native-modal-picker.git#525bf444ac6b19251d99cafb2b603998a501b5af)
├── react-native-parallax-scroll-view@0.19.0
├── react-native-picker@4.0.19
├── react-native-router-flux@3.39.2
├── react-native-scrollable-tab-view@0.5.5
├── react-native-segment-io-analytics@0.0.6 (git+https://github.com/cvquant/react-native-segment-io-analytics.git#ddd164370104c09156261e5abad5bbebbe9f53ad)
├── react-native-sentry@0.23.2
├── react-native-share@1.0.20
├── react-native-shimmer@0.1.0 (git+https://github.com/cvquant/react-native-shimmer.git#75dbe9592465ca9606504c7471591c910fd22cf6)
├── react-native-simple-toast@0.0.6
├── react-native-slider-android@1.1.2
├── react-native-snap-carousel@2.1.4
├── react-native-vector-icons@4.3.0
├── react-native-webview-android@1.1.10
├── react-navigation@1.0.0-beta.11
├── react-redux@4.4.8
├── reactotron-react-native@1.11.1
├── redux@3.6.0
├── redux-actions@2.2.1
├── redux-form@6.8.0
├── redux-logger@2.10.2
├── redux-persist@4.8.0
├── redux-thunk@2.2.0
├── reselect@2.5.4
└── uuid@3.0.1
Any ideas?
@prithsharma Please run react-native unlink react-native-sentry
twice and make sure there are no signs left of Sentry in your project (check Frameworks, libraries, AppDelegate).
After that link it again, these errors indicate that your project isn't set up correctly.
I also experienced this issue and what worked for me was modifying AppDelegate.m
as follows:
// replace this:
#import "RCTRootView.h"
// with:
#import <React/RCTRootView.h>
NB: this was on another project, however I had the same error and came here after searching for a solution 😃 NB2: I'm using RN 0.48
@HazAT I am getting same issue with RNSentry.h file not found, but it should ask for <React/RNSentry.h> which is in the project and react native is > 0.40
@karla Can you verify you Xcode project contain RNSentry
?
@HazAT no it is not containing this... I have seen that a manual update for pods, could solve that, but I prefer not to update pods due to the way my project is configured, so I am wonder if there is any aditional way to solve it? thanks
@karla Well, you would have to manually include it in your project. Since this is different depending on your setup we did not really document it since it's different for every project. But basically what you have to do is drag & drop RNSentry.xcodeproj
into your project.
Also, you should be able to pin the versions of your Pods and update them anytime.
I met same error Use of undeclared identifier 'RNSentry
after following manual setup
I found it is important the order of [RNSentry installWithRootView:rootView];
My AppDelegate.m
when error occurred.
...
[RNSentry installWithRootView:rootView];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"myApp"
initialProperties:nil
launchOptions:launchOptions];
...
changed AppDelegate.m
when worked fine
...
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"myApp"
initialProperties:nil
launchOptions:launchOptions];
[RNSentry installWithRootView:rootView];
...
If you met same error, be sure to locate [RNSentry installWithRootView:rootView];
after RCTRootView
.
I found it by investigating the difference of my app and example. Thanks for preparing example!
EDIT: needed to do the 3rd step here: https://facebook.github.io/react-native/docs/linking-libraries-ios.html#step-3 -- it's all good now
@HazAT I am having this issue as I'm trying to build my app for iOS in CircleCI:
▸ Copying RNDeviceInfo/RNDeviceInfo.h
▸ Building mobile/mobile [Release]
▸ Check Dependencies
▸ Running script '[CP] Check Pods Manifest.lock'
▸ Running script 'Upload Debug Symbols to Sentry'
▸ Compiling AppDelegate.m
❌ /Users/distiller/mobile/ios/mobile/AppDelegate.m:19:9: 'RNSentry.h' file not found
#import "RNSentry.h" // This is used for versions of react < 0.40
Things I have tried:
1) Unlink twice via react-native unlink react-native-sentry
and then react-native link react-native-sentry
2) [RNSentry installWithRootView:rootView];
is located correctly per @sasurau4
3) I can see in XCode that RNSentry is inside Libraries
node -v && npm -v && npm ls --prod --depth=0
v8.9.4
6.4.1
mobile@0.0.1 /Users/cihat/fatlama/mobile
├── @storybook/cli@4.0.6
├── algoliasearch@3.27.0
├── algoliasearch-helper@2.25.0
├── analytics-react-native@1.2.0
├── appcenter@1.5.0
├── appcenter-analytics@1.5.0
├── appcenter-crashes@1.5.0
├── apphub@0.5.1
├── axios@0.16.2
├── env2@2.2.0
├── flow@0.2.3
├── flow-typed@2.4.0
├── format-json@1.0.3
├── formik@1.3.1
├── fse@3.1.0
├── haversine@1.1.0
├── intl@1.2.5
├── jest-styled-components@7.0.0-2
├── libphonenumber-js@1.5.1
├── moment@2.22.1
├── pusher-js@4.2.2
├── ramda@0.25.0
├── react@16.6.1
├── react-instantsearch@4.5.2
├── react-intl@2.5.0
├── react-intl-native@2.1.2
├── react-intl-redux@2.0.2
├── react-native@0.57.5
├── react-native-actionsheet@2.4.2
├── react-native-android-keyboard-adjust@1.1.1
├── react-native-appsee@2.4.11
├── react-native-calendars@1.19.3
├── react-native-check-box@2.1.0
├── react-native-communications@2.2.1
├── react-native-device-info@0.17.4
├── react-native-dotenv@0.2.0
├── react-native-fbsdk@0.6.3 invalid
├── react-native-fcm@10.0.3
├── react-native-firebase@5.1.0
├── react-native-flags@1.0.0
├── react-native-google-signin@0.12.0
├── react-native-hyperlink@0.0.14
├── react-native-image-crop-picker@0.21.2
├── react-native-intercom@10.2.0
├── react-native-iphone-x-helper@1.2.0
├── react-native-keyboard-done-button@1.0.0
├── react-native-linear-gradient@2.4.0
├── react-native-map-link@2.1.0
├── react-native-maps@0.22.0
├── react-native-mixpanel@0.0.16
├── react-native-sentry@0.39.1
├── react-native-snap-carousel@3.7.5
├── react-native-sortable-grid@2.0.0
├── react-native-view-more-text@2.0.0
├── react-navigation@1.5.11
├── react-navigation-redux-helpers@1.0.5
├── react-redux@5.0.7
├── UNMET PEER DEPENDENCY redux@4.0.0
├── redux-actions@2.4.0
├── redux-form@7.3.0
├── redux-logger@3.0.6
├── redux-persist@5.10.0
├── UNMET PEER DEPENDENCY redux-saga@0.14.6
├── redux-saga-test-plan@3.7.0
├── redux-thunk@2.2.0
├── reselect@3.0.1
├── UNMET PEER DEPENDENCY styled-components@4.1.1
├── styled-system@3.1.11
├── tipsi-stripe@5.2.1
├── uploadcare@0.4.5
└── why-did-you-update@0.1.1
_Platform: ios simulator
after "react-native link react-native-sentry", i get error 'Use of undeclared identifier 'RNSentry''.
i find that, the link command add
[RNSentry installWithRootView:rootView];
in appdelegate.m file ,but not include some .h file, is right?