Xcode 13.3 beta 3:“swift package init”显示警告:“~/Library/org.swift.swiftpm/collections.json 已被弃用”,但不知道如何使用新的

Saj*_*jon 82 xcode swift swift-package-manager matlab-spm xcode13

刚刚升级到 Xcode 13.3 beta 3(从 Xcode 13.2.1)并运行swift package init. 它生成了一个弃用警告,我以前没有见过这个:

\n
warning: Usage of /Users/sajjon/Library/org.swift.swiftpm/collections.json has been deprecated. Please delete it and use the new /Users/sajjon/Library/org.swift.swiftpm/configuration/collections.json instead.\n
Run Code Online (Sandbox Code Playgroud)\n

但我不知道如何“使用新的......代替”?事实上我什至不知道它是如何或何时org.swift.swiftpm/collections.json创建的。

\n

该怎么办?

\n

完整打印:

\n
~/Developer/DeleteMe \xe2\x8c\x9a 13:57:37\n$ swift package init\n2022-02-25 13:57:42.211 xcodebuild[54679:13318505] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionSentinelHostApplications for extension Xcode.DebuggerFoundation.AppExtensionHosts.watchOS of plug-in com.apple.dt.IDEWatchSupportCore\n2022-02-25 13:57:42.212 xcodebuild[54679:13318505] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionPointIdentifierToBundleIdentifier for extension Xcode.DebuggerFoundation.AppExtensionToBundleIdentifierMap.watchOS of plug-in com.apple.dt.IDEWatchSupportCore\n2022-02-25 13:57:43.052 xcodebuild[54754:13318823] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionSentinelHostApplications for extension Xcode.DebuggerFoundation.AppExtensionHosts.watchOS of plug-in com.apple.dt.IDEWatchSupportCore\n2022-02-25 13:57:43.053 xcodebuild[54754:13318823] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionPointIdentifierToBundleIdentifier for extension Xcode.DebuggerFoundation.AppExtensionToBundleIdentifierMap.watchOS of plug-in com.apple.dt.IDEWatchSupportCore\nwarning: Usage of /Users/sajjon/Library/org.swift.swiftpm/collections.json has been deprecated. Please delete it and use the new /Users/sajjon/Library/org.swift.swiftpm/configuration/collections.json instead.\nCreating library package: DeleteMe\n
Run Code Online (Sandbox Code Playgroud)\n

小智 124

我安装 Xcode 14.0 后遇到了这个问题。删除org.swift.swiftpm对我有用:

  1. 确保与 SPM 相关的任何内容都没有运行,包括 Xcode。在删除任何内容之前将其全部关闭。

  2. 转到目录并删除整个org.swift.swiftpm目录(不仅是collection目录,而是整个org.swift.swiftpm目录),如果还有org.swift.swiftpm.lock,也删除该目录。

在此输入图像描述

  • 快速、简单。当我重新启动 XCode 时,警告就消失了。 (4认同)

Nik*_*ikR 22

该警告表明您需要删除该文件。

Please delete it and use the new /Users/sajjon/Library/org.swift.swiftpm/configuration/collections.json instead.
Run Code Online (Sandbox Code Playgroud)

所以请删除它,这会有帮助。


Jav*_*olo 13

根据 @jalone 的评论,这可能会导致 Xcode 在打开项目时崩溃。在我的例子中它没有这样做,但我拥有的只是通用的苹果集合:https://developer.apple.com/swift/packages/collections/apple.json

谨慎行事

看起来我需要做的就是运行这个来消除警告。

rm ~/.swiftpm/config/collections.json
Run Code Online (Sandbox Code Playgroud)

应该有一个额外的collections.json位置,~/.swiftpm/config/configuration/collections.json即您使用时现在存储包的位置

swift package-collection add <package.json>
Run Code Online (Sandbox Code Playgroud)

有关更多信息,请参阅此处的SE 提案文档

  • 请注意,删除文件后,xcode 13.3 在我的实例上打开项目时会持续崩溃。我必须清理大量缓存和文件才能使项目再次打开(并且警告至少消失了)。遗憾的是,我建议您找到替代解决方案。 (5认同)