project.xcproj: unresolvedPackage when a repository URL ends in an extension other than .git

未关闭 适合新手
#1,202 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
76/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
swift

调研方向

从 XCRemoteSwiftPackageReference.name 开始,然后追踪 XCProjDecoder.makePackageProductDependency 如何使用 packagesByName,以及编码器如何推导包名。使用以 .ios_sdk 结尾的仓库 URL 重现故障;项目能够加载,且包身份处理与 SwiftPM 移除完整路径扩展名的行为一致时,即为完成。

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

描述

Summary

Decoding a project.xcproj fails with XCProjError.unresolvedPackage when a remote package's repository URL ends in a path extension other than .git. Xcode 27.2 writes the package's SwiftPM identity into package-product-members, but XCProjDecoder looks packages up by XCRemoteSwiftPackageReference.name, which only strips .git.

Reproduction

  1. Add https://github.com/Ometria/ometria.ios_sdk as a package dependency in an Xcode project.
  2. Convert it with xcodebuild -project App.xcodeproj -convert-project "Xcode Project" (or the Project Format menu in Xcode 27.2).
  3. Load the project with XcodeProj (we hit it through Periphery).

The converted file contains:

"packages": [
  {
    "kind": "remote",
    "repository": "https://github.com/Ometria/ometria.ios_sdk",
    "version": { "up-to-next-major-version": "1.9.1" },
  },
],
...
"package-product-members": [
  {
    "package": "ometria",
    "product-name": "Ometria",
    "build-phase": { "build-phase": "frameworks" },
  },
],

Actual

Error: (XCProjError) The project has no Swift package named 'ometria'

Expected

The project loads. Xcode and xcodebuild -list read the same file without problems.

Cause

XCRemoteSwiftPackageReference.name is:

repositoryURL?.split(separator: "/").last?.replacingOccurrences(of: ".git", with: "")

which gives ometria.ios_sdk. Xcode drops the whole path extension, as SwiftPM does when deriving a package identity from a URL, giving ometria. Other packages in the same project keep their casing (MobileSDK-iOS), so only the extension handling differs. XCProjDecoder.makePackageProductDependency then misses packagesByName["ometria"].

Deriving the name used by packagesByName (and by the encoder) with the path extension removed, instead of only .git, would fix it.

Environment

  • Xcode 27.2 (27B52)
  • Periphery 1.0.0.beta.9 with XcodeProj's project.xcproj support
主要语言
Swift
星标
2.2k
派生
356
平均合并
4 小时 48 分钟
30 天内合并 PR
10

环境准备

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

从这里开始

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

tuist/XcodeProj 的其他 Issue

查看 tuist/XcodeProj 的全部 Issue

相似的 Issue

更多 Swift Issue

把新 issue 发到你的邮箱

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