run-ios --buildFolder installs the app from the default DerivedData instead of the build folder
维护者通常 2 天内回复
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 55/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- react-native, typescript
- 领域
- cli, mobile-dev
调研方向
Start with packages/cli-platform-apple/src/commands/buildCommand/buildProject.ts and packages/cli-platform-apple/src/commands/runCommand/getBuildSettings.ts, then trace how runOnSimulator.ts, runOnDevice.ts and createRun.ts pass build options. Check how -showBuildSettings resolves TARGET_BUILD_DIR when --buildFolder is set. Done means the run paths install or open the app from that build folder; the issue names no tests.
由索引模型根据 Issue 内容生成。
描述
Environment
System:
OS: macOS 27.0.1
Binaries:
Node: 24.18.0
pnpm: 11
IDEs:
Xcode: 27.0/27A266a
npmPackages:
"@react-native-community/cli-platform-apple": 20.2.0
react-native: 0.85
The bug does not depend on the Xcode version; the relevant code is unchanged on main (21.0.0-alpha.1).
Description
run-ios --buildFolder <dir> builds into <dir> but installs the app from Xcode's default DerivedData.
buildProject passes the folder to the build as -derivedDataPath <dir>. After the build, installApp resolves the app through getBuildSettings, which runs xcodebuild … -showBuildSettings -json without -derivedDataPath. TARGET_BUILD_DIR therefore points into ~/Library/Developer/Xcode/DerivedData/<Project>-<hash>/… and not into <dir>. As a result:
-
If the default DerivedData holds an older build of the project (for example from an Xcode IDE build), the CLI installs and launches that stale
.appwithout any warning. -
If it holds no build, the command fails after
success Successfully built the app:UnhandledPromiseRejection: … The promise rejected with the reason "Error: target build directory /Users/…/Library/Developer/Xcode/DerivedData/<Project>-<hash>/Build/Products/Debug-iphonesimulator does not exist".
The same applies to runOnDevice (physical device and Mac Catalyst) and to openApp (macOS), because they all go through getBuildSettings.
--binary-path does not work around this: it skips the build and passes buildOutput: '', so getBuildSettings throws on getPlatformName('') (#2517).
Code references on main:
packages/cli-platform-apple/src/commands/buildCommand/buildProject.tsadds-derivedDataPathfromargs.buildFolder.packages/cli-platform-apple/src/commands/runCommand/getBuildSettings.tsbuilds the-showBuildSettingscall without it.runOnSimulator.ts,runOnDevice.tsandcreateRun.ts(macOS) do not passargs.buildFoldertoinstallApp/openApp/getBuildSettings.
Related: createRun calls process.chdir(sourceDir) (the ios/ directory) before building, so a relative --buildFolder resolves against ios/ and not the project root. The option description does not say which directory it is relative to.
Proposed fix: thread buildFolder from the run paths into getBuildSettings and append -derivedDataPath <buildFolder> to the -showBuildSettings call when it is set. I applied this as a local patch on 20.2.0: run-ios --buildFolder build/DerivedData then installs and launches the freshly built app from ios/build/DerivedData/Build/Products/Debug-iphonesimulator/. PR to follow.
Reproducible Demo
- In any React Native project, make sure the default DerivedData has no build for it:
rm -rf ~/Library/Developer/Xcode/DerivedData/<Project>-*. - Run
npx react-native run-ios --buildFolder build/DerivedData. - The build succeeds into
ios/build/DerivedData, then the CLI fails withtarget build directory …/Library/Developer/Xcode/DerivedData/<Project>-<hash>/Build/Products/Debug-iphonesimulator does not exist.
Expected: the CLI installs and launches the app it just built in ios/build/DerivedData.
- 主要语言
- TypeScript
- 星标
- 2.9k
- 派生
- 948
- 平均合并
- 10 天 19 小时
- 30 天内合并 PR
- 1
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
react-native-community/cli 的其他 Issue
-
run-ios --udid <physical device> throws "No simulator available" because the fallback simulator is resolved eagerly可能已有人在做 @huytdps13400 于 41 天前认领。 未关闭bug report
难度 2/5 1-3 小时 新手友好度 84/100
react-native-community/cli#2826 ·
维护者通常 2 天内回复
-
`project.ios.automaticPodsInstallation` default of `true` never applies unless `project.ios` is explicitly declared in `react-native.config.js`可能已有人在做 @huytdps13400 于 41 天前认领。 未关闭bug report
难度 2/5 1-3 小时 新手友好度 78/100
react-native-community/cli#2825 ·
维护者通常 2 天内回复
-
run-ios: "Unable to boot device in current state: Booted" alert when the simulator is already booted可能已有人在做 @bryandent 于 85 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
react-native-community/cli#2820 ·
维护者通常 2 天内回复
-
run-ios on Xcode 27: DeviceHub opens no window when the simulator is shut down可能已有人在做 @rakodev 于 2 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 25/100
react-native-community/cli#2866 · 1 条评论 ·
维护者通常 2 天内回复
-
难度 4/5 3-5 天 新手友好度 48/100
react-native-community/cli#2852 ·
维护者通常 2 天内回复
查看 react-native-community/cli 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 85/100
Comfy-Org/ComfyUI_frontend#20346 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 90/100
decentralized-identity/didwebvh-ts#203 ·
维护者通常 1 天内回复
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
难度 2/5 1-3 小时 新手友好度 65/100
lingdojo/kana-dojo#31791 · 1 条评论 · 5 个 reaction ·
维护者通常 1 天内回复
-
Telegram webhook: line breaks lost since switch to rich messages可能已有人在做 @Kshot3000 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
github_actions security
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复