react-native-version: Syntax Error while versioning iOS

PS F:\Shared Desktop\ROBOCRAZE\RnD\alphacare\hospital_app_react> yarn version --minor yarn version v1.6.0 warning …\package.json: No license field info Current version: 0.1.0-beta question New version: error Invalid semver version question New version: 0.2.0 info New version: 0.2.0 $ react-native-version [RNV] Versioning Android… [RNV] Android updated [RNV] Versioning iOS… [RNV] SyntaxError: Expected “"”, “\'”, “\"”, “\n”, or [^\"] but “\” found.

After setting up post version hook, running the command yarn version --minor produces this error.

Platform: Windows 10

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 2
  • Comments: 24 (6 by maintainers)

Commits related to this issue

Most upvoted comments

If it helps, offending line was:

shellScript = "export SENTRY_PROPERTIES=sentry.properties\nexport NODE_BINARY=node\n../node_modules/@sentry/cli/bin/sentry-cli react-native xcode \\\n../node_modules/react-native/scripts/react-native-xcode.sh\n";

Had to remove the \\ from \\\n

from https://www.npmjs.com/package/@sentry/react-native

In our case it was newest react with @sentry/react-native having offending lines in shell script (copied from official Sentry documentation about workaround for RN >0.69) Here is the working shell script line in case anyone needs it:

/bin/sh -c "$WITH_ENVIRONMENT '$SENTRY_CLI_PATH react-native xcode $REACT_NATIVE_XCODE'"

Facing the same problem after adding a custom build script, have been using the library without any issues for a year, but stuck now. Lots of backslashes in the script to escape quotes and spaces, so not sure how to fix it.

EDIT: I’ve created an issue in pbxproj-dom to see if they have any ideas on a fix

If it helps, offending line was:

shellScript = "export SENTRY_PROPERTIES=sentry.properties\nexport NODE_BINARY=node\n../node_modules/@sentry/cli/bin/sentry-cli react-native xcode \\\n../node_modules/react-native/scripts/react-native-xcode.sh\n";

Had to remove the \\ from \\\n

from https://www.npmjs.com/package/@sentry/react-native

your command line appers like this?

shellScript = "export SENTRY_PROPERTIES=sentry.properties\nexport NODE_BINARY=node\n../node_modules/@sentry/cli/bin/sentry-cli react-native xcode \n../node_modules/react-native/scripts/react-native-xcode.sh\n";

Found the issue, the problem comes from React Native made in Windows that will have backslashed paths inside pbxproj. It’s not a problem from your package at all @stovmascript . Check strings that are like this:

"\"$(SRCROOT)/$(TARGET_NAME)\"",
or
"$(SRCROOT)\..\node_modules\react-xxxx",

and change them to

"$(SRCROOT)/$(TARGET_NAME)",
accordingly
"$(SRCROOT)/../node_modules/react-xxxx",

Faced the same issue with Mac. Resolved with changing

shellScript = "# This script configures Expo modules and generates the modules provider file.\nbash -l -c \"./Pods/Target\\ Support\\ Files/Pods-tracemoe_react_native/expo-configure-project.sh\"\n";

to

shellScript = "# This script configures Expo modules and generates the modules provider file.\nbash -l -c \"./Pods/Target' 'Support' 'Files/Pods-tracemoe_react_native/expo-configure-project.sh\"\n";

The key: \\ to ' ' Root reason - the file path with space in it.

SyntaxError: Expected “"”, “\'”, “\"”, “\n”, or [^\"] but “\” found.

similar to above it was Sentry shell script. I am on a mac. shellScript = “export SENTRY_PROPERTIES=sentry.properties\nexport …”

in several places I had to replace $WITH_ENVIRONMENT \\\ with $WITH_ENVIRONMENT \ and $REACT_NATIVE_XCODE\\\ with $REACT_NATIVE_XCODE\

i have the same error on MacOs now. any one fixed this please ?

were you able to fix it?

i have the same error on MacOs now. any one fixed this please ?

I’m experiencing this issue with Sentry.

I suspect this line is causing the problem, but I don’t know how to fix it:

shellScript = "export SENTRY_PROPERTIES=sentry.properties\nexport EXTRA_PACKAGER_ARGS=\"--sourcemap-output $DERIVED_FILE_DIR/main.jsbundle.map\"\nset -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 \\\"../node_modules/@sentry/cli/bin/sentry-cli react-native xcode $REACT_NATIVE_XCODE\\\"\"\n\n/bin/sh ../node_modules/@sentry/react-native/scripts/collect-modules.sh\n";

Any way to solve this?

It’s just because Windows uses \ instead of / for paths and when paths are written to pbxproj when using react-native link, they will contain backslashes, it still works when your compile on a Mac, but it will crash with the pbxproj-dom parser package that you use. You could maybe add a “Common issues” page on your README for future users.