react-native-version icon indicating copy to clipboard operation
react-native-version copied to clipboard

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

Open alainib opened this issue 2 years ago • 11 comments

hello

i'm getting this error now. i'm note sur from where it come and absolutly not how to fix it.

i'm running

yarn version --new-version 0.2.8-0 --message chore(release): v%s

my package version are

"react-native": "0.72.4", "react-native-version": "4.0.0",

i was working good with lower version of react native, i'm using macos so no problem of slash or antislash like with windows in path.

any tips are more than welcomed thanks

alainib avatar Aug 23 '23 10:08 alainib

If you have expo 49, have a look at the script expo-configure

Or if you have sentry, look at the script (fix can be found in issue on this repo)

batical avatar Aug 23 '23 11:08 batical

thanks for helping @batical
i use expo 49 yes but not for building, only to use some of there component

"expo": "^49.0.0",
"expo-constants": "^14.2.1",
"expo-contacts": "^12.2.0",
"expo-image-manipulator": "^11.3.0",
"expo-linear-gradient": "^12.3.0",
"expo-media-library": "^15.4.1",
"expo-modules-core": "^1.5.9",
"expo-splash-screen": "^0.20.5",
"@expo/[email protected]"

the only match with expo-configure i have is expo-configure-project.sh in path

  • .../ios/Pods/Target Support Files/Pods-MYAPP-MYAPPTests/expo-configure-project.sh
  • .../ios/Pods/Target Support Files/Pods-MYAPP/expo-configure-project.sh

but i don't see any in the content


#!/usr/bin/env bash
# @generated by expo-modules-autolinking

set -eo pipefail

function with_node() {
  # Start with a default
  export NODE_BINARY=$(command -v node)

  # Override the default with the global environment
  ENV_PATH="$PODS_ROOT/../.xcode.env"
  if [[ -f "$ENV_PATH" ]]; then
    source "$ENV_PATH"
  fi

  # Override the global with the local environment
  LOCAL_ENV_PATH="${ENV_PATH}.local"
  if [[ -f "$LOCAL_ENV_PATH" ]]; then
    source "$LOCAL_ENV_PATH"
  fi

  if [[ -n "$NODE_BINARY" && -x "$NODE_BINARY" ]]; then
    echo "Node found at: ${NODE_BINARY}"
  else
    cat >&2 << NODE_NOT_FOUND
error: Could not find "node" executable while running an Xcode build script.
You need to specify the path to your Node.js executable by defining an environment variable named NODE_BINARY in your project's .xcode.env or .xcode.env.local file.
You can set this up quickly by running:

echo "export NODE_BINARY=\$(command -v node)" >> .xcode.env

in the ios folder of your project.
NODE_NOT_FOUND

    exit 1
  fi

  # Execute argument, if present
  if [[ "$#" -gt 0 ]]; then
    "$NODE_BINARY" "$@"
  fi
}

with_node --no-warnings --eval "require('expo-modules-autolinking')(process.argv.slice(1))" generate-package-list  --target "/Users/dev/my-app/ios/Pods/Target Support Files/Pods-MyApp/ExpoModulesProvider.swift"

maybe this line is wrong in /Users/dev/my-app/ios/MyApp.xcodeproj/project.pbxproj

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

alainib avatar Aug 23 '23 13:08 alainib

yes the line in the project.pbxproj file was the culprit for me

don't have access to my code right now but i had to change it

batical avatar Aug 23 '23 13:08 batical

Did you resolve it? @alainib

danilocanalle avatar Oct 09 '23 14:10 danilocanalle

There are two approaches to temporary solve this issue:

  1. Delete \\ from project.pbxproj file, run yarn version and then revert those changes. But it's very inconvenient to do it manually. Using automatic replacement like sed is an option, but the postversion script in the package.json will look terrible

  2. Use -L, --legacy for react-native-version. It seams that agvtool works good with \\ characters.

For now I use the second approach.

cryser29 avatar Nov 21 '23 11:11 cryser29

  1. Use -L, --legacy for react-native-version. It seams that agvtool works good with \ characters.

That did not work for me because my CFBundleVersion and CURRENT_PROJECT_VERSION gets reset for some reason.

mieszko4 avatar Dec 11 '23 14:12 mieszko4

change

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\""

to

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'"

krmao avatar Dec 12 '23 07:12 krmao

Related issue https://github.com/NativeScript/pbxproj-dom/issues/9

mieszko4 avatar May 08 '24 11:05 mieszko4

Changing \\ to ' ' worked for me (as suggested in https://github.com/stovmascript/react-native-version/issues/52#issuecomment-1870914924)

mieszko4 avatar May 08 '24 11:05 mieszko4