[Bug]: `cap sync ios` doesn't support Xcode 27.2's JSON project format (`project.xcproj`)
维护者通常 1 天内回复
还没有人认领这个 Issue。
- #8608 来自 @erkamyaman —— 已关闭,未合并
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 65/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- ios, typescript
调研方向
先使用 Xcode 27.0 或 27.2 进行复现,然后阅读 cli/src/util/spm.ts 和 cli/src/ios/common.ts,尤其是 getMajoriOSVersion()。检查 cli/src/ios/common.ts、cli/src/tasks/migrate.ts、cli/src/tasks/migrate-uiscene.ts、cli/src/util/xcode.ts 和 cli/src/config.ts 中列出的其他 project.pbxproj 调用方。转换后的项目能够正确同步,或者不支持的情况以明确的非零结果失败,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Capacitor Version
💊 Capacitor Doctor 💊
Latest Dependencies:
@capacitor/cli: 8.5.2
@capacitor/core: 8.5.2
@capacitor/android: 8.5.2
@capacitor/ios: 8.5.2
Installed Dependencies:
@capacitor/android: not installed
@capacitor/core: 8.5.2
@capacitor/cli: 8.5.2
@capacitor/ios: 8.5.2
[success] iOS looking great! 👌
Other API Details
Xcode 27.2 beta (27B5019j), also reproduced building with Xcode 27.0
macOS 27.0
Node 24.15.0
Swift Package Manager (the default for new Capacitor 8 apps)
Platforms Affected
- iOS
- Android
- Web
Current Behavior
Xcode 27.2 beta adds a JSON-based project format. Its release notes say it's "more readable, merge-friendly, and easier for coding agents to edit", and projects in this format also open in Xcode 27.0. Converting a project replaces App.xcodeproj/project.pbxproj with App.xcodeproj/project.xcproj.
The CLI still reads project.pbxproj directly, so after converting:
npx cap sync ioslogsUnable to write to …/CapApp-SPM/Package.swiftwithENOENT: no such file or directory, open '…/App.xcodeproj/project.pbxproj', but exits with code 0.CapApp-SPM/Package.swiftis never rewritten, so plugins you add or remove never reach iOS.- After removing a plugin, Xcode then fails with
Could not resolve package dependencies, becausePackage.swiftstill points at the removed package. npx cap doctorstill reports "iOS looking great".
Xcode 27.0 and 27.2 both build the converted project fine, so only the CLI is affected.
Expected Behavior
The CLI works with both project.pbxproj and project.xcproj. At minimum, it should fail with a non-zero exit code and a clear message instead of reporting success.
Project Reproduction
With a blank app, no plugins of mine involved:
mkdir blank-cap && cd blank-cap && mkdir www && echo '<h1>hi</h1>' > www/index.html
npm init -y
npm install @capacitor/[email protected] @capacitor/[email protected] @capacitor/[email protected]
npm install -D @capacitor/[email protected]
echo '{ "appId": "com.example.blank", "appName": "blank", "webDir": "www" }' > capacitor.config.json
npx cap add ios
npx cap sync ios # works
# Convert to the new format (Xcode 27.2 beta); the same option is in Xcode's File inspector
xcodebuild -convert-project "Xcode Project" -project ios/App/App.xcodeproj
npm uninstall @capacitor/app
npx cap sync ios # logs the ENOENT error above, exits 0
grep CapacitorApp ios/App/CapApp-SPM/Package.swift # the removed plugin is still listed
xcodebuild -project ios/App/App.xcodeproj -scheme App -destination 'generic/platform=iOS Simulator' build
# error: Could not resolve package dependencies
Additional Information
Places on main that read project.pbxproj:
| File | What it does | Effect with project.xcproj |
|---|---|---|
cli/src/ios/common.ts, getMajoriOSVersion() |
Reads IPHONEOS_DEPLOYMENT_TARGET |
Throws. Called from util/spm.ts (this bug) and ios/update.ts |
cli/src/ios/common.ts, editProjectSettingsIOS() |
Sets PRODUCT_BUNDLE_IDENTIFIER on cap add ios |
Would throw (new projects are still .pbxproj for now) |
cli/src/tasks/migrate.ts |
Bumps the deployment target | Throws |
cli/src/tasks/migrate-uiscene.ts + cli/src/util/xcode.ts |
Adds SceneDelegate.swift through the xcode package, which only parses .pbxproj |
Throws |
cli/src/config.ts, determineIOSWebDirAbs() |
Checks where public lives |
Error is caught, no effect |
The new file keeps the same build settings as JSON keys, for example:
"IPHONEOS_DEPLOYMENT_TARGET": "15.0",
"PRODUCT_BUNDLE_IDENTIFIER": "com.example.blank",
It allows trailing commas, so JSON.parse can't read it as-is. For the deployment target and bundle ID, falling back to project.xcproj when project.pbxproj is missing, with regexes that accept both KEY = value; and "KEY": "value", would cover cap sync, cap add and cap migrate. The UIScene migration needs its own change, since the xcode package can't edit the new file.
- 主要语言
- TypeScript
- 星标
- 17.1k
- 派生
- 1.3k
- 平均合并
- 1 天 22 小时
- 30 天内合并 PR
- 26
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ionic-team/capacitor 的其他 Issue
-
triage
难度 2/5 1-3 小时 新手友好度 76/100
ionic-team/capacitor#8759 ·
维护者通常 1 天内回复
-
[Bug]: Plugin call after navigation can be answered before reply proxy is updated可能已有人在做 @MateStrysewske 于 71 天前认领。 未关闭triage
难度 2/5 1-3 小时 新手友好度 84/100
ionic-team/capacitor#8616 ·
维护者通常 1 天内回复
-
help wanted
难度 2/5 1-3 小时 新手友好度 68/100
ionic-team/capacitor#8574 · 3 条评论 ·
维护者通常 1 天内回复
-
SystemBars: safe area CSS injection throws "Cannot read properties of null" on startup (Android 16)可能已有人在做 @kttalley 于 62 天前认领。 未关闭triage
难度 2/5 1-3 小时 新手友好度 78/100
ionic-team/capacitor#8530 · 2 条评论 ·
维护者通常 1 天内回复
-
fix(android): remove unchecked Java compilation warnings可能已有人在做 @Ajamuar 于 15 天前认领。 未关闭triage
难度 2/5 1-3 小时 新手友好度 78/100
ionic-team/capacitor#8529 · 1 条评论 ·
维护者通常 1 天内回复
查看 ionic-team/capacitor 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
prio:low scope:world
难度 2/5 1-3 小时 新手友好度 83/100
OliverRomhagen/vrigstad-joyride#849 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
genfeedai/genfeed.ai#11916 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
erkamyaman/rust-anything#1153 ·
维护者通常 1 天内回复
-
The Phase 5 report says 0.3.0 waits for the live check可能已有人在做 @fzn0x 今天认领。 未关闭documentation
难度 1/5 1 小时以内 新手友好度 85/100
维护者通常 1 天内回复