13

所以我想在 MacOS 10.15 Beta (19A471t) 上的 Xcode 11.0 beta (11M336w) 中编辑 swift 包中的一些文件。

我们以https://github.com/AndyQ/NFCPassportReader为例。

它有一个使用来自 GitHub 的 repo 的示例应用程序。假设我想对源代码进行一些更改。如何告诉系统我要编辑包?

swift package edit NFCPassportReader我在命令行上尝试了“ ”。

  1. 如果我从示例应用程序的根文件夹运行它,我会得到“ error: root manifest not found

  2. 如果我从包的根目录运行它,我会得到“ error: Could not find dependency 'NFCPassportReader'

我需要采取哪些步骤才能在编辑模式下(在 Xcode 11 中)以及从哪个目录获取包?

Ps 这是来自 repo 的 Package.swift 文件

// swift-tools-version:5.1
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "NFCPassportReader",
    platforms: [.iOS(.v13)],
    products: [
        // Products define the executables and libraries produced by a package, and make them visible to other packages.
        .library(
            name: "NFCPassportReader",
            targets: ["NFCPassportReader"]),
    ],
    dependencies: [
        // Dependencies declare other packages that this package depends on.
        // .package(url: /* package url */, from: "1.0.0"),
    ],
    targets: [
        // Targets are the basic building blocks of a package. A target can define a module or a test suite.
        // Targets can depend on other targets in this package, and on products in packages which this package depends on.
        .target(
            name: "NFCPassportReader",
            dependencies: []),
        .testTarget(
            name: "NFCPassportReaderTests",
            dependencies: ["NFCPassportReader"]),
    ]
)
4

1 回答 1

25

如果您在本地克隆一个包并将其拖到您的项目或工作区中,则该本地副本将覆盖它被引用的任何(只读)远程依赖项。然后,您可以根据需要编辑包的本地副本。

您可以在 WWDC2019 创建 Swift 包的视频 23 分钟后看到有关此工作流程的更多信息:https ://developer.apple.com/videos/play/wwdc2019/410/

于 2019-06-18T03:25:02.473 回答