Skip to content

Syntax Error while versioning iOS #52

Description

@aruldd

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

Activity

  1. stovmascript commented on May 28, 2018

    @stovmascript
    Owner

    Looks similar to: #38 (comment) and: #38 (comment)

  2. stovmascript commented on May 28, 2018

    @stovmascript
    Owner

    @aruldd Is it possible you have manually set up some paths in your Xcode project file?

  3. VinceBT commented on May 30, 2018

    @VinceBT

    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",
    
  4. stovmascript commented on May 31, 2018

    @stovmascript
    Owner

    @VinceBT Awesome, I'll capture this message and print out something more meaningful.

  5. stovmascript commented on May 31, 2018

    @stovmascript
    Owner

    @VinceBT I also suspect that it's more of an issue with react-native link because a newly initialized project doesn't have any $(SRCROOT) strings yet. Which would explain why everything worked for me in: #38 (comment).

  6. added a commit that references this issue on May 31, 2018
  7. VinceBT commented on May 31, 2018

    @VinceBT

    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.

  8. VinceBT commented on Jun 1, 2018

    @VinceBT

    @aruldd Tell us if it worked for you so @stovmascript can close

  9. added 2 commits that reference this issue on Jun 4, 2018
    08fa8eb
    7a9ca24
  10. added a commit that references this issue on Jun 4, 2018
    0824b72
  11. Maushundb commented on Nov 25, 2019

    @Maushundb

    I'm getting this issue when running on Mac OSX, is that expected? I'm on 3.2.0

  12. Maushundb commented on Nov 25, 2019

    @Maushundb

    Yeah there seems to be some paths in pbxproj that cocoapods installs that has the windows syntax as well. Had to go in and edit them manually, now it works. This does happen on macs as well apparently, might wanna update docs.

  13. stovmascript commented on Nov 26, 2019

    @stovmascript
    Owner

    Hmm, this seems like a bug with cocoapods, or even some specific packages. I'm wondering if we could find the offending upstream code and report it...

  14. 1 remaining item

  15. Maushundb commented on Nov 26, 2019

    @Maushundb

    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

  16. vladwhd commented on Jan 24, 2020

    @vladwhd

    I have a more "funny" case. My error was "SyntaxError: Expected """, "\'", "\"", "\n", or [^\\"] but "\" found.", so I searched for \ in the project.pbxproj and the only place where it was present was

    shellScript = "# Name of the resource we're selectively copying\nFILENAME=GoogleService-Info.plist\n\nBUILD_TYPE=$(echo ${CONFIGURATION} | sed -E \"s/\\s*(Release|Debug) \\s*//\")\nORIGINAL_PATH=${PROJECT_DIR}/${TARGET_NAME}/Firebase/${BUILD_TYPE}/${FILENAME}\nDESTINATION_DIR=${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app\n\n# Make sure the prod version of GoogleService-Info.plist exists\necho \"Looking for ${ORIGINAL_PATH}\"\nif [ ! -f $ORIGINAL_PATH ]\nthen\n echo \"No ${FILENAME} found for build type ${BUILD_TYPE}. Please ensure it's in the proper directory.\"\n exit 1\nfi\n\necho \"Will copy ${ORIGINAL_PATH} to final destination: ${DESTINATION_DIR}\"\n\ncp \"${ORIGINAL_PATH}\" \"${DESTINATION_DIR}\"\n";

    So basically it failed parsing the shell script, which is kind of weird. I removed this script and the error was gone, so it's this indeed.
    I will change my script to fix this, but it shouldn't have happened in the first place.

  17. fabricio0915 commented on Feb 18, 2020

    @fabricio0915

    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";
    
  18. sanjaypojo commented on May 19, 2020

    @sanjaypojo

    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

  19. sanjaypojo commented on May 28, 2020

    @sanjaypojo

    Just to clarify though -- I'm facing this issue on macOS. Here's the exact error:

    [RNV] SyntaxError: Expected ",", "/*", or [ \t\n\r] but "B" found.

    EDIT: Managed to resolve the issue by checking through my build settings and removing some \ characters as suggested

  20. otkach-yara commented on May 18, 2021

    @otkach-yara

    I have fixed this issue by moving the script, which caused the error, from project.pbxproj to separate .sh file and then just added a reference to that file. Also you should make your sh file executable by chmod +x script.sh

    Screenshot 2021-05-18 at 17 53 52

  21. bimusiek commented on Nov 30, 2022

    @bimusiek

    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'"
    
  22. marcinniemirski commented on May 24, 2023

    @marcinniemirski

    Here is the final version of working shellScript in Sentry v5 and RN v0.71

    shellScript = "set -e\nexport SENTRY_PROPERTIES=sentry.properties\nexport EXTRA_PACKAGER_ARGS=\"--sourcemap-output $DERIVED_FILE_DIR/main.jsbundle.map\"\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\nSENTRY_CLI_PATH=\"../node_modules/@sentry/cli/bin/sentry-cli\"\n/bin/sh -c \"$WITH_ENVIRONMENT $SENTRY_CLI_PATH react-native xcode\n$REACT_NATIVE_XCODE\"\n/bin/sh ../node_modules/@sentry/react-native/scripts/collect-modules.sh\n";
  23. n-ii-ma commented on Jun 13, 2023

    @n-ii-ma

    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?

  24. alainib commented on Aug 23, 2023

    @alainib

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

  25. erickgtzh commented on Sep 25, 2023

    @erickgtzh

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

    were you able to fix it?

  26. 29er commented on Oct 20, 2023

    @29er

    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\

  27. Leslie-Wong-H commented on Dec 28, 2023

    @Leslie-Wong-H

    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.

  28. moisesmiss commented on Jul 6, 2024

    @moisesmiss

    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.

    This works form me, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions