xcodebuild 无法获取 swift 包

问题描述 投票:0回答:1

我有一个 swift Xcode (14.3.1) 项目,它对 swift 包有一些依赖项,其中一个来自开发人员公共 github 存储库,而使用 Xcode 编译项目时,一旦使用新的源代码控制帐户,一切都可以正常工作(

 Xcode->Settings->Accounts
)使用正确的 git PAT 密钥添加。

尝试使用

xcodebuild
编译相同的项目时,它不起作用:

xcodebuild -project SwiftPackage.xcodeproj -scheme SwiftPackage
Command line invocation:
    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -project SwiftPackage.xcodeproj -scheme SwiftPackage

User defaults from command line:
    IDEPackageSupportUseBuiltinSCM = YES

Resolve Package Graph

Fetching from https://github.com/SwiftyJSON/SwiftyJSON.git (cached)

Fetching from https://github.com/apple/swift-system.git (cached)

Fetching from https://github.com/USERAME/PACKAGE(cached)
skipping cache due to an error: Couldn’t fetch updates from remote repositories:
    fatal: could not read Username for 'https://github.com': terminal prompts disabled

Fetching from https://github.com/USERAME/PACKAGE (cached)

skipping cache due to an error: Couldn’t fetch updates from remote repositories:
    fatal: could not read Username for 'https://github.com': terminal prompts disabled

  Failed to clone repository https://github.com//USERAME/PACKAGE:
    Cloning into bare repository '/Users/USERNAME/Library/Developer/Xcode/DerivedData/SwiftPackage-crqxawsrsuqwaabsatcmymebbugz/SourcePackages/repositories/PACKAGE-21375f48'...
    fatal: could not read Username for 'https://github.com': terminal prompts disabled

SwiftyJSON
swift-system
已正确获取,但
PACKAGE
没有..

我尝试了 Stackoverflow 上找到的不同解决方案,例如配置

.netrc
文件、修改
*.xcodeproj
使包 URL 包含 PAT (PAT@github...)、更改
*.resolved
文件以再次包含PAT,这确实有效,但看起来像是黑客攻击而不是修复。

此外,将 Xcode 中的克隆方法 (

Xcode->Settings->Accounts
) 更改为
HTTPS
SSH
不会改变任何内容。

我需要的是一个干净的解决方案,例如添加

-scmProvider xcode
,遗憾的是它不起作用,换句话说:是否有一个针对
xcodebuild
的选项,使其像 Xcode 一样工作并正确获取包?

continuous-integration xcodebuild swift-package-manager
1个回答
0
投票

您是否尝试过以下操作:

  1. 看起来你的 xcodebuild 命令正在使用你的系统 git 而不是它自己的嵌入式 git (它忽略本地/全局 git 配置设置)。由于它可以工作并使用您在通过 Xcode 的 UI 构建时所需的帐户凭据,因此您可以尝试将其切换回使用 Xcode 自己的嵌入式 git:
    defaults write com.apple.dt.Xcode IDEPackageSupportUseBuiltinSCM NO
  2. 然后删除所有派生数据(Xcode 关闭):
    rm -rf ~/Library/Caches/org.swift.swiftpm ~/Library/Developer/Xcode/DerivedData
  3. 然后先尝试单独解决包依赖关系(Xcode 仍然关闭):
    xcodebuild -resolvePackageDependencies -project ./YourProjectName/YourProjectName.xcodeproj
  4. 然后就可以尝试用xcodebuild正常编译了。

或者,如果您在本地环境中拥有依赖的 git 设置,则可以尝试使用全局 git 配置中依赖的任何内容来更新 Xcode 的嵌入式 git 配置和设置。

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.