Description
Environment
System:
OS: macOS 14.0
CPU: (10) arm64 Apple M1 Max
Memory: 4.11 GB / 64.00 GB
Shell:
version: 3.6.1
path: /opt/homebrew/bin/fish
Binaries:
Node:
version: 18.18.0
path: ~/.local/bin/node
Yarn:
version: 3.6.1
path: /opt/homebrew/bin/yarn
npm:
version: 9.8.1
path: ~/.local/bin/npm
Watchman:
version: 2023.10.09.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.12.1
path: /Users/tido/.gem/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 23.0
- iOS 17.0
- macOS 14.0
- tvOS 17.0
- watchOS 10.0
Android SDK:
API Levels:
- "31"
- "33"
- "34"
Build Tools:
- 30.0.3
- 31.0.0
- 33.0.0
- 33.0.1
System Images:
- android-33 | Google APIs ARM 64 v8a
Android NDK: Not Found
IDEs:
Android Studio: 2022.2 AI-222.4459.24.2221.10121639
Xcode:
version: 15.0/15A240d
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.8.1
path: /usr/bin/javac
Ruby:
version: 3.2.2
path: /opt/homebrew/opt/ruby/bin/ruby
npmPackages:
"@react-native-community/cli":
installed: 12.0.0-alpha.17
wanted: 12.0.0-alpha.17
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.73.0-rc.2
wanted: ^0.72.0
react-native-macos:
installed: 0.72.0
wanted: ^0.72.0
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: false
newArchEnabled: true
iOS:
hermesEnabled: false
newArchEnabled: false
Description
react-native run-ios
fails if .xcodeproj
doesn't live next to Podfile
:
error Cannot read properties of undefined (reading 'schemes').
TypeError: Cannot read properties of undefined (reading 'schemes')
at getConfiguration (/~/example/node_modules/@react-native-community/cli-platform-ios/build/commands/buildIOS/getConfiguration.js:31:43)
at Object.runIOS [as func] (/~/example/node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/index.js:97:66)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Command.handleAction (/~/example/node_modules/@react-native-community/cli/build/index.js:118:9)
It looks like CLI is again assuming that .xcodeproj
files live next to Podfile
and .xcworkspace
. In 8.0, there was a significant amount of work to get rid of this assumption, but it looks like we've regressed. I did a quick investigation and it looks like run-ios
is trying to find the scheme, but fails because xcodebuild -list -json
returns:
{
"workspace" : {
"name" : "Example",
"schemes" : [
"boost",
"DoubleConversion",
"Example",
"Example-Tests",
"FBLazyVector",
"FBReactNativeSpec",
"fmt",
"glog",
"Pods-ReactTestApp",
"Pods-ReactTestApp-ReactTestAppTests",
"RCT-Folly",
"RCTRequired",
"RCTTypeSafety",
"React",
"React-callinvoker",
~
"ReactCommon",
"ReactNativeHost",
"ReactTestApp",
"ReactTestApp-DevSupport",
"ReactTestApp-Resources",
"SocketRocket",
"Yoga"
]
}
}
getProjectInfo()
assumes project
exists:
cli/packages/cli-platform-ios/src/tools/getProjectInfo.ts
Lines 7 to 8 in 1749483
But it doesn't, as we can see above. Further, getConfiguration()
also assumes that project.schemes[0]
is the target scheme:
In this case, it would wrongly choose boost
. In a different app, this could pick another random library.
Reproducible Demo
git clone https://github.com/microsoft/react-native-test-app.git
cd react-native-test-app
npm run set-react-version 0.73 -- --core-only
yarn
cd example
pod install --project-directory=ios
# Because of an issue with finding CocoaPods, you may have to remove lines 68-70 in
# node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/index.js
yarn ios