stovmascript / react-native-version

:1234: Version your React Native or Expo app in a `npm version` fashion.
MIT License
579 stars 75 forks source link

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

Open alainib opened 1 year ago

alainib commented 1 year ago

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

batical commented 1 year ago

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)

alainib commented 1 year ago

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/cli@0.10.11"

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

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";
batical commented 1 year ago

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

danilocanalle commented 1 year ago

Did you resolve it? @alainib

cryser29 commented 11 months ago

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.

mieszko4 commented 10 months ago
  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.

krmao commented 10 months ago

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'"
mieszko4 commented 6 months ago

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

mieszko4 commented 6 months ago

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