react-native-community / cli

The React Native Community CLI - command line tools to help you build RN apps
MIT License
2.41k stars 905 forks source link

Couldn't find "PLATFORM_NAME" variable in Xcodebuild output when providing binaryPath #2517

Open emilundg opened 1 month ago

emilundg commented 1 month ago

Environment

System:
  OS: macOS 14.6.1
  CPU: (12) arm64 Apple M2 Pro
  Memory: 435.45 MB / 32.00 GB
  Shell:
    version: 3.6.1
    path: /opt/homebrew/bin/fish
Binaries:
  Node:
    version: 22.7.0
    path: /opt/homebrew/bin/node
  Yarn:
    version: 1.22.19
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.8.2
    path: /opt/homebrew/bin/npm
  Watchman: Not Found
Managers:
  CocoaPods:
    version: 1.15.0
    path: /Users/kgwc595/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.0
      - iOS 18.0
      - macOS 15.0
      - tvOS 18.0
      - visionOS 2.0
      - watchOS 11.0
  Android SDK: Not Found
IDEs:
  Android Studio: 2023.3 AI-233.14808.21.2331.11709847
  Xcode:
    version: 16.0/16A242d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.11
    path: /opt/homebrew/opt/openjdk@17/bin/javac
  Ruby:
    version: 3.1.4
    path: /Users/kgwc595/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 13.6.1
    wanted: 13.6.1
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.74.1
    wanted: 0.74.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: false
  newArchEnabled: false

Description

When providing the option --binary-path to run-ios the following error happens and fails the install:

Couldn't find "PLATFORM_NAME variable in Xcodebuild output

After doing some digging in the code for cli-platform-apple we see that in the file getBuildSettings.ts the function getPlatformName is called with buildOutput. The problem is that in the file runOnSimulator.ts (that calls getBuildSettings) the buildOutput variable is set as an empty string when providing a binaryPath.

Reproducible Demo

Haven't tried in a fresh React Native project but it should be present there as well. So create a React Native project with an iOS artifact already built and then run:

yarn react-native run-ios --binary-path= ./ios/build/Build/Products/Debug-iphonesimulator/MyApp.app