getsentry / sentry-react-native

Official Sentry SDK for React Native
https://sentry.io
MIT License
1.59k stars 337 forks source link

Sentry wizard install into bare react-native project breaks use of react-native-version because of code added to project.pbxproj #3888

Open eedeebee opened 5 months ago

eedeebee commented 5 months ago

OS:

Platform:

SDK:

SDK version: 0.0.0

react-native version: 0.0.0

Are you using Expo?

Are you using sentry.io or on-premise?


I have the following issue:

The sentry install wizard updated my project.pbxproj file and made it unparseable by react-native-version

Previous bits

shellScript = "set -e\n\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT $REACT_NATIVE_XCODE\"\n";

New (and unparse-able bits) result:

shellScript = "set -e\n\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT \\\"/bin/sh ../node_modules/@sentry/react-native/scripts/sentry-xcode.sh $REACT_NATIVE_XCODE\\\"\"\n";

Error from react-nativer-version

[RNV] SyntaxError: Expected "\"", "\\'", "\\\"", "\\n", or [^\\"] but "\\" found.
eedeebee commented 5 months ago

Thinking this might be a workaround ?

shellScript = "set -e\n\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT '/bin/sh ../node_modules/@sentry/react-native/scripts/sentry-xcode.sh $REACT_NATIVE_XCODE'\"\n";
krystofwoldrich commented 5 months ago

Hi @eedeebee, thank you for the message, the core of the issue is in the react-native-version parser which can't handle test = "\"" escaped quotation.

The workaround is as you mentioned to use '.

set -e

WITH_ENVIRONMENT="../node_modules/react-native/scripts/xcode/with-environment.sh"
REACT_NATIVE_XCODE="../node_modules/react-native/scripts/react-native-xcode.sh"

/bin/sh -c "$WITH_ENVIRONMENT '/bin/sh ../node_modules/@sentry/react-native/scripts/sentry-xcode.sh $REACT_NATIVE_XCODE'"