How do I put a swift package in Edit Mode?

我与影子孤独终老i 提交于 2019-12-06 04:59:06

问题


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

Let's take https://github.com/AndyQ/NFCPassportReader as an example.

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?

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

  1. If I run it from the example app's root folder I get "error: root manifest not found"

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

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

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

回答1:


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.

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/



来源:https://stackoverflow.com/questions/56627369/how-do-i-put-a-swift-package-in-edit-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!