我有一个 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 一样工作并正确获取包?
您是否尝试过以下操作:
defaults write com.apple.dt.Xcode IDEPackageSupportUseBuiltinSCM NO
rm -rf ~/Library/Caches/org.swift.swiftpm ~/Library/Developer/Xcode/DerivedData
xcodebuild -resolvePackageDependencies -project ./YourProjectName/YourProjectName.xcodeproj
或者,如果您在本地环境中拥有依赖的 git 设置,则可以尝试使用全局 git 配置中依赖的任何内容来更新 Xcode 的嵌入式 git 配置和设置。