[Bug]: Dynamically resolve target name in cap run ios

未关闭
#8,024 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
ios, typescript
领域
cli, mobile

调研方向

从 cli/src/ios/run.ts 中链接的 bundle 路径逻辑开始,然后检查 xcodebuild -scheme -showBuildSettings 如何公开 TARGET_NAME。使用链接的复现项目来验证,当 scheme 名称和 target 名称不同时,deployment 能够解析 target 的 .app 路径。

由索引模型根据 Issue 内容生成。

描述

triage
Capacitor Version

💊 Capacitor Doctor 💊

Latest Dependencies:

@capacitor/cli: 7.2.0
@capacitor/core: 7.2.0
@capacitor/android: 7.2.0
@capacitor/ios: 7.2.0

Installed Dependencies:

@capacitor/cli: 7.2.0
@capacitor/core: 7.2.0
@capacitor/android: 7.2.0
@capacitor/ios: 7.2.0

Other API Details
not relevant
Platforms Affected
  • iOS
  • Android
  • Web
Current Behavior

When running a Capacitor iOS application which has multiple schemes with cap run ios --scheme Dev --configuration Dev the deployment fails with

Deploying Dev.app to 00008101-001525992141001E - failed!
[error] ERR_UNKNOWN: Path
        '<project_dir>/ios/DerivedData/<id>/Build/Products/Dev-iphoneos/Dev.app'
        not found

as the runIOS function assumes that the .app name matches the scheme name (i.e., ${runScheme}.app). See: ios/run.ts#L59

However, by default this is not always correct, as the .app name is determined by the target name, not the scheme name. This can cause deployment to fail because the .app bundle is not found at the expected path, when the scheme and target names differ.

Expected Behavior

The Capacitor CLI should dynamically query the actual TARGET_NAME associated with the selected scheme using xcodebuild -showBuildSettings, ensuring the correct .app name is used during deployment. This would make runIOS more robust and compatible with a broader range of Xcode project configurations.

Project Reproduction

IsAvaible/cap-run-dynamic-target-name-reproduction

Additional Information

This can be fixed by adding a helper function that invokes:

xcodebuild -scheme <scheme> -showBuildSettings

...and extracts the TARGET_NAME from the output. This resolved name should then be used in place of ${runScheme} when determining the final app bundle path.

This enhancement would:

  • Improve compatibility with multi-target/-scheme projects
  • Prevent .app not found errors
  • Align behavior with actual Xcode project structure

Let me know if you'd like a PR for this :).

主要语言
TypeScript
星标
17.1k
派生
1.3k
平均合并
1 天 22 小时
30 天内合并 PR
26

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ionic-team/capacitor 的其他 Issue

查看 ionic-team/capacitor 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。