Swiftpack.co - SwiftDocOrg/SwiftPackageManifest as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by SwiftDocOrg.
SwiftDocOrg/SwiftPackageManifest 0.1.0
A package for decoding the output of `swift package dump-package`
⭐️ 15
🕓 3 years ago
.package(url: "https://github.com/SwiftDocOrg/SwiftPackageManifest.git", from: "0.1.0")

SwiftPackageManifest

CI Documentation

A package that provides information about a Swift package, as encoded by running swift package dump-package in a directory containing a valid Package.swift manifest.

SwiftPackageManifest is similar to but distinct from the Swift Package Manager's PackageDescription module It's intended to be a lightweight, portable alternative to the official library for the sole purpose of reading generated Swift package manifests in JSON format.

Warning: The format of swift package dump-package isn't versioned, and any changes to this format between Swift releases may cause decoding to fail.

Usage

In a directory containing a valid Package.swift manifest, run the following command to generate a JSON representation:

$ swift package dump-package > Package.json

Read the contents of that file and use JSONDecoder to deserialize a Package object from it:

import Foundation
import SwiftPackageManifest

let json = try! Data(contentsOfFile: "path/to/Package.json", options: [])
let decoder = JSONDecoder()
let package = try decoder.decode(Package.self, from: json)

Installation

Swift Package Manager

Add the SwiftPackageManifest package to your target dependencies in Package.swift:

import PackageDescription

let package = Package(
  name: "YourProject",
  dependencies: [
    .package(
        url: "https://github.com/SwiftDocOrg/SwiftPackageManifest",
        from: "0.1.0"
    ),
  ]
)

Add SwiftPackageManifest as a dependency to your target(s):

targets: [
.target(
    name: "YourTarget",
    dependencies: ["SwiftPackageManifest"]),

License

MIT

Contact

Mattt (@mattt)

GitHub

link
Stars: 15
Last commit: 3 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics