如何在 Xcode 11 中删除 Swift Package Dependency?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/56718121/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 10:59:05  来源:igfitidea点击:

How to delete Swift Package Dependency in Xcode 11?

xcodeswift-package-managerxcode11

提问by Charlie Fish

I have a project in Xcode 11 that I added Swift Package Manager dependencies to. I now realized that I no longer need one of the package dependencies I previously added to my project.

我在 Xcode 11 中有一个项目,我向其中添加了 Swift Package Manager 依赖项。我现在意识到我不再需要我之前添加到我的项目中的包依赖项之一。

As you can see below, there are no options under File > Swift Packagesfor deleting a packager from Swift Package Manager for this project.

正如您在下面看到的,在File > Swift Packages从 Swift 包管理器中删除此项目的打包器时没有选项。

Swift Packages Menu Options

Swift 包菜单选项

I have tried removing the package from the array in the project.xcworkspace/xcshareddata/swiftpm/Package.resolvedfile. But it still doesn't remove it from Xcode, and the next time I Update to Latest Package Versionsit readds the entry to the Package.resolvedfile.

我尝试从project.xcworkspace/xcshareddata/swiftpm/Package.resolved文件中的数组中删除包。但它仍然没有从 Xcode 中删除它,下次我Update to Latest Package Versions读取Package.resolved文件的条目时。

How can I delete a Swift Package Manager dependency in my project?

如何删除项目中的 Swift Package Manager 依赖项?

回答by Pierre

  1. Open Xcode
  2. Select your project
  3. Look at the top middle
  4. Select Swift Package Managermenu
  1. 打开 Xcode
  2. 选择您的项目
  3. 看上面中间
  4. 选择Swift 包管理器菜单

You'll be able to manage your packages (add / remove)

您将能够管理您的包裹(添加/删除)

enter image description here

在此处输入图片说明

回答by possen

In addition to Pierre's answer, this was driving me crazy, I had a sub project that I was editing, I forgot about that (it was in a subfolder). Even though I removed it in the "Swift Packages" pane it kept coming back. Removing that sub folder reference made sure the PM dependencies went away.

除了皮埃尔的回答,这让我发疯,我有一个正在编辑的子项目,我忘记了(它在一个子文件夹中)。即使我在“Swift Packages”窗格中删除了它,它仍然会回来。删除该子文件夹引用可确保 PM 依赖项消失。

回答by toupper

Firstly I removed it from dependencies and targets in Package.swift, then i regenerated my project file with swift package generate-xcodeproj

首先我从 Package.swift 中的依赖项和目标中删除它,然后我重新生成了我的项目文件 swift package generate-xcodeproj