Search code examples
react-nativesentry

How do I customize the location of index.js with Sentry in React Native?


Our bundle entry point is at src/index.tsx, which appears not to match the Sentry default of ./index.js.

Sentry is failing on sentry-cli react-native-xcode with the error EOF while parsing a value at line 1 column 0.

Using debug log level, I see:

+ ENTRY_FILE=index.js
...
Error: The resource `/Users/lukecwilliams/Projects/mobile2mr/index.js` was not found.

And in the actual CLI command, this is being run: --entry-file index.js

We need instead --entry-file src/index.tsx. How can we customize this? I can't find an answer in the docs or source code.


I've found this solution (custom build script) but it's still not working.

I have a script in the project root:

sentry-cli-xcode-build.sh:

./node_modules/react-native/packager/react-native-xcode.sh ./src/index.tsx

And in the build command in project.pbxproj:

shellScript = "export SENTRY_PROPERTIES=sentry.properties\nexport EXTRA_PACKAGER_ARGS=\"--sourcemap-output $DERIVED_FILE_DIR/main.jsbundle.map\"\nexport NODE_BINARY=node\n../node_modules/@sentry/cli/bin/sentry-cli react-native xcode ../sentry-cli-xcode-build.sh";

But the result is a fairly ambiguous: error: Permission denied (os error 13)

Do I need to change the directory setup somehow? I don't see a concrete example in Sentry docs or the GH answer above regarding where to put the script and how to reference it exactly.


Solution

  • It turns out that this build step should simply be disabled in iOS projects using Bitcode (which is the default). So, we have no more need to run a custom build script.

    We'll use Fastlane afterward to upload debug symbols.

    Docs for reference:: https://docs.sentry.io/platforms/react-native/#ios-specifics