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.
If I run it from the example app's root folder I get "error: root
manifest not found
"
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"]),
]
)
swift file, or package manifest, describes the configuration for the Swift package. You can double-click it in Finder to open the package in Xcode. The package manifest uses Swift and the PackageDescription framework to define the package's name, products, targets, dependencies on other packages, and so on.
Basically, adding a local Swift Package requires two steps. Drag and drop the local package into the Xcode project or workspace. Add it to the Frameworks, Libraries, and Embedded Content section in app targets general pane.
To add a package dependency to your Xcode project, select File > Swift Packages > Add Package Dependency and enter its repository URL.
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With