Skip to content

Cannot pass arguments to subcommand in with-environment.sh for iOS build #54140

@davidliu

Description

@davidliu

Description

Prior to 0.82.0, you could pass arguments to the subcommand for with-environment.sh like so:

set -e

WITH_ENVIRONMENT="$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh"
REACT_NATIVE_XCODE="\"$REACT_NATIVE_PATH/scripts/react-native-xcode.sh index.ts\""

/bin/sh -c "$WITH_ENVIRONMENT $REACT_NATIVE_XCODE"

This is the code used in the default "Bundle React Native code and images" build phase for iOS, with the REACT_NATIVE_XCODE command altered to pass in an extra argument. The react-native-xcode.sh script takes in arguments, one of which was to specify the entry file.

In 0.82.0, this change altered the behavior to treat the spaces inside as part of the whole string. An easy fix would be to change this line to "$@" instead to support proper argument passing.

Steps to reproduce

  1. Yarn install and pod install.
  2. Open the iOS XCode workspace
  3. Change signing settings as needed, and build.
  4. Observe build failure.

React Native Version

0.82.0

Affected Platforms

Build - MacOS

Output of npx @react-native-community/cli info

System:
  OS: macOS 15.5
  CPU: (10) arm64 Apple M1 Pro
  Memory: 185.23 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 22.17.1
    path: /Users/davidliu/.nvm/versions/node/v22.17.1/bin/node
  Yarn:
    version: 3.6.4
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.9.2
    path: /Users/davidliu/.nvm/versions/node/v22.17.1/bin/npm
  Watchman:
    version: 2025.02.17.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /Users/davidliu/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.5
      - iOS 18.5
      - macOS 15.5
      - tvOS 18.5
      - visionOS 2.5
      - watchOS 11.5
  Android SDK:
    API Levels:
      - "24"
      - "27"
      - "28"
      - "29"
      - "30"
      - "31"
      - "32"
      - "33"
      - "34"
      - "35"
      - "36"
    Build Tools:
      - 27.0.3
      - 28.0.3
      - 29.0.0
      - 29.0.2
      - 30.0.2
      - 30.0.3
      - 31.0.0
      - 32.0.0
      - 33.0.0
      - 33.0.1
      - 33.0.2
      - 34.0.0
      - 35.0.0
      - 35.0.0
      - 35.0.0
      - 36.0.0
    Android NDK: Not Found
IDEs:
  Android Studio: 2025.1 AI-251.26094.121.2512.13840223
  Xcode:
    version: 16.4/16F6
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.14
    path: /opt/homebrew/opt/sdkman-cli/libexec/candidates/java/current/bin/javac
  Ruby:
    version: 3.3.5
    path: /Users/davidliu/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 20.0.0
    wanted: 20.0.0
  react:
    installed: 19.1.1
    wanted: 19.1.1
  react-native:
    installed: 0.82.0
    wanted: 0.82.0
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true

Stacktrace or Logs

+ WITH_ENVIRONMENT=/Users/davidliu/example/ios/Pods/../../node_modules/react-native/scripts/xcode/with-environment.sh
+ REACT_NATIVE_XCODE='"/Users/davidliu/github/example/ios/Pods/../../node_modules/react-native/scripts/react-native-xcode.sh index.ts"'
+ /bin/sh -c '/Users/davidliu/github/example/ios/Pods/../../node_modules/react-native/scripts/xcode/with-environment.sh "/Users/davidliu/github/example/ios/Pods/../../node_modules/react-native/scripts/react-native-xcode.sh index.ts"'
Node found at: /Users/davidliu/.nvm/versions/node/v21.5.0/bin/node
/Users/davidliu/github/example/ios/Pods/../../node_modules/react-native/scripts/xcode/with-environment.sh: line 46: /Users/davidliu/github/example/ios/Pods/../../node_modules/react-native/scripts/react-native-xcode.sh index.ts: No such file or directory

MANDATORY Reproducer

https://github.com/davidliu/ios_arguments_bug_082

Screenshots and Videos

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions