如何将 swift 包置于编辑模式? [英] How do I put a swift package in Edit Mode?

查看:36
本文介绍了如何将 swift 包置于编辑模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

So I want to edit some files in a swift package in Xcode 11.0 beta (11M336w) on MacOS 10.15 Beta (19A471t).

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

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

It has an example app which uses the repo from GitHub. Suppose I want to make some source code changes. How do I tell the system I want to edit the package?

我在命令行上尝试了swift package edit NFCPassportReader".

I tried "swift package edit NFCPassportReader" on the command line.

  1. 如果我从示例应用程序的根文件夹运行它,我得到error: root未找到清单"

如果我从包的根目录运行它,我得到错误:无法找到依赖 'NFCPassportReader'"

If I run it from the root of the package I get "error: Could not find dependency 'NFCPassportReader'"

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

What steps do I need to take for get the package in edit mode (in Xcode 11), and from which directory?

附言这是来自 repo 的 Package.swift 文件

P.s. Here is the Package.swift file from the repo

// 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"]),
    ]
)

推荐答案

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

If you clone a package locally and drag it into your project or workspace, that local copy will override the (read-only) remote dependency anywhere it was referenced. You can then edit the local copy of the package as needed.

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

You can see more on this workflow about 23 minutes into the WWDC2019 video for Creating Swift Packages: https://developer.apple.com/videos/play/wwdc2019/410/

这篇关于如何将 swift 包置于编辑模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆