File

public struct File : CustomStringConvertible

A Swift file

Initializers

  • Creates a File instance which represents a Swift file that will be created

    Declaration

    Swift

    @inlinable
    public init(name: String, indent: String, @CodeBuilder body: () -> CodeRepresentable)

    Parameters

    name

    The name of the Swift file to be created

    indent

    The string used as indent characters. Should only be whitespace

    body

    The Swift code that represents the body of the file

Stored Properties

  • The name of the Swift file

    Declaration

    Swift

    public let name: String
  • The string used for indenting Swift code

    Declaration

    Swift

    public let indent: String
  • The current date at the creation of this instance

    Declaration

    Swift

    public let date: Date
  • The body of the Swift file

    Declaration

    Swift

    public let code: Code

Computed Properties

  • Declaration

    Swift

    public var description: String { get }
  • A String representation of the File’s code content

    Declaration

    Swift

    public var string: String { get }

Methods

  • Creates/overwrites a Swift file at the given path. Throws if there is an error encountered during the I/O operation

    Declaration

    Swift

    @inlinable
    public func write(to pathString: String = "") throws

    Parameters

    pathString

    The string representation of a file path. For example “~/Downloads”