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
- 分支
- 952
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
- 沒有 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 於 62 天前認領。 未關閉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 於 62 天前認領。 未關閉bug report
難度 2/5 1-3 小時 新手友好度 78/100
react-native-community/cli#2825 ·
維護者通常 2 天內回覆
-
run-ios on Xcode 27: DeviceHub opens no window when the simulator is shut down可能已有人在做 @rakodev 於 23 天前認領。 未關閉
難度 3/5 1-2 天 新手友好度 25/100
react-native-community/cli#2866 · 2 則留言 ·
維護者通常 2 天內回覆
-
Tons of errors are ignored可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉
難度 4/5 3-5 天 新手友好度 48/100
react-native-community/cli#2852 ·
維護者通常 2 天內回覆
-
run-android: "Could not find the correct install APK file" for single-dimension camelCase product flavors when targeting a specific device可能已有人在做 @huytdps13400 於 22 天前認領。 未關閉
難度 3/5 1-2 天 新手友好度 68/100
react-native-community/cli#2851 · 1 則留言 · 2 個 reaction ·
維護者通常 2 天內回覆
查看 react-native-community/cli 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 75/100
維護者通常 1 天內回覆
-
難度 1/5 1-3 小時 新手友好度 84/100
-
難度 2/5 1-3 小時 新手友好度 83/100
keptinventory/kept#336 ·
維護者通常 1 天內回覆
-
good first issue
難度 2/5 1-3 小時 新手友好度 84/100
-
hemi-earn
難度 2/5 1-3 小時 新手友好度 72/100
vetro-protocol/vetro-monorepo#1013 ·
維護者通常 1 天內回覆