Manifest

public final class Manifest: Codable

An interface for a package’s manifest.

  • The current environment that the Manifest is being used in.

    Declaration

    Swift

    public static var environment: Environment = .commandline
  • Gets the current project’s manifest.

    Declaration

    Swift

    public static var current: Manifest
  • A custom path to the manifest. This property gets set to ./Package.swift when the static.current property is used.

    Declaration

    Swift

    public let path: String?
  • Data that acts as the manifest file.

    Declaration

    Swift

    public private(set) var data: Data?
  • Declaration

    Swift

    public init(path: String)
  • Declaration

    Swift

    public init(data: Data)
  • Declaration

    Swift

    public required init(from decoder: Decoder) throws
  • Declaration

    Swift

    public func encode(to encoder: Encoder) throws
  • Gets the contents of the project’s manifest as Data.

    Throws

    Errors that occur if there is a badly formed URL or the manifest is not found.

    Declaration

    Swift

    public func contents()throws -> Data

    Return Value

    The manifest’s contents.

  • Gets the contents of the project’s manifest as an NSMutableString.

    Throws

    Errors that occur if there is a badly formed URL or the manifest is not found.

    Declaration

    Swift

    public func contents()throws -> NSMutableString

    Return Value

    The manifest’s contents.

  • Gets the contents of the project’s manifest as a String.

    Throws

    Errors that occur if there is a badly formed URL or the manifest is not found.

    Declaration

    Swift

    public func contents()throws -> String

    Return Value

    The manifest’s contents.

  • Rewrites the contents of the package’s manifest.

    Throws

    ManifestError.badURL if the URL to the manifest cannot be created.

    Declaration

    Swift

    public func write(with string: String)throws

    Parameters

    string

    The data to rewrite the manifest with.

  • Rewrites the contents of the package’s manifest.

    Throws

    ManifestError.badURL if the URL to the manifest cannot be created.

    Declaration

    Swift

    public func write(with string: NSMutableString)throws

    Parameters

    string

    The string to rewrite the manifest with.

  • Rests the manifest to its orginal state when the project was created without extraneous comments or whitespace.

    Throws

    Errors when reading or writing the manifest.

    Declaration

    Swift

    public func reset()throws
  • Get all the elements in Package.dependencies array from the project’s manifest.

    Throws

    Errors that occur when creating a RegEx pattern or reading or writing the manifest.

    Declaration

    Swift

    public func dependencies()throws -> [Dependency]

    Return Value

    Package.dependencies

  • Get an element in Package.dependencies array from the project’s manifest.

    Throws

    Errors that occur when creating a RegEx pattern or reading or writing the manifest.

    Declaration

    Swift

    public func dependency(withURL url: String)throws -> Dependency?

    Parameters

    url

    The URL of the dependency to fetch.

    Return Value

    Package.dependencies

  • Gets the name of the Package declaration in the project’s manifest.

    Throws

    Errors that occur when creating a RegEx pattern or reading or writing the manifest.

    Declaration

    Swift

    public func name(equals name: String? = nil)throws -> String

    Parameters

    name

    A new name for the Package declaration. If nil is passed in, the name remains the same.

    Return Value

    The value passed into the manifest’s Package initializer.

  • Gets the value of the Package.pkgConfig property.

    Throws

    Errors that occur when creating a RegEx pattern or reading or writing the manifest.

    Declaration

    Swift

    public func packageConfig()throws -> String?

    Return Value

    Package.pkgConfig

  • Sets the value of the Package.pkgConfig property in the project’s manifest.

    Throws

    Errors that occur when creating a RegEx pattern or reading or writing the manifest.

    Declaration

    Swift

    public func packageConfig(equals string: String?)throws

    Parameters

    string

    The new value for Package.pkgConfig.

  • Gets all the Product instances in the current manifest.

    Declaration

    Swift

    public func products()throws -> [Product]
  • Gets a single Product instances from the current manifest.

    Declaration

    Swift

    public func product(as type: ProductType = .library, withName name: String)throws -> Product?

    Parameters

    type

    Wheather the product is an executable or library (default).

    name

    The name of the product to fetch.

  • Get all the elements in Package.providers from the project’s manifest.

    Throws

    Errors that occur when creating a RegEx pattern or reading or writing the manifest.

    Declaration

    Swift

    public func providers()throws -> [Provider]

    Return Value

    Package.providers

  • Gets the contents of the package’s Package.resolved file as a data structure.

    Throws

    ManifestError.badPath if the path to the .resolved file is malformed.

    Declaration

    Swift

    public func resolved()throws -> Resolved

    Return Value

    The contents of the packages .resolved file.

  • Gets the data from the package’s .resolved file about a package with a given name.

    Throws

    Errors that occur when fetching the data.

    Declaration

    Swift

    public func package(withName name: String)throws -> Pin?

    Parameters

    name

    The name of the package to fetch.

    Return Value

    The package’s pin data.

  • Gets the data from the package’s .resolved file about a package with a given repository URL.

    Throws

    Errors that occur when fetching the data.

    Declaration

    Swift

    public func package(withURL url: String)throws -> Pin?

    Parameters

    name

    The URL of the package to fetch.

    Return Value

    The package’s pin data.

  • Gets the targets declared in the project’s manifest.

    Throws

    Errors that occur while fetching the manifest contents or create the regex for maching the targets.

    Declaration

    Swift

    public func targets()throws -> [Target]

    Return Value

    The project’s targets parsed into data structures.

  • Gets a target declared in the project’s manifest.

    Throws

    Errors that occur while fetching the manifest contents or create the regex for maching the targets.

    Declaration

    Swift

    public func target(test: Bool = false, withName name: String)throws -> Target?

    Parameters

    test

    Wheather the target to fetch is a test target or not.

    name

    The name of the target to fetch.

    Return Value

    The project’s targets parsed into data structures.