Swift required to build this package. import PackageDescription let package = Package( name: "SPMDemo", products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. .library( name: "SPMDemo", targets: ["SPMDemo"]), ], 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 this package depends on. .target( name: "SPMDemo", dependencies: []), .testTarget( name: "SPMDemoTests", dependencies: ["SPMDemo"]), ] )
Swift required to build this package. import PackageDescription let package = Package( name: "SPMDemo", products: [ .library( name: "SPMDemo", targets: [“SPMDemo"] ), ], dependencies: [], targets: [ .target( name: "SPMDemo", dependencies: []) ] ) Remember to modify the tool version here if needed. Some new features of SPM PlugIn are based on versions 5.6 - 5.7.
Swift requir import PackageDescription let package = Package( name: "Utilities", products: [ // Products define the executables and libraries a package prod .library( name: "Extensions", targets: ["Extensions"] ), .library( name: "BuilderHelper", targets: ["Buildable", "KeyPathConstraints"] ), .library( name: "Buildable", targets: ["Buildable"] ) ], targets: [ // Targets are the basic building blocks of a package. A target // Targets can depend on other targets in this package, and on .target(name: "Extensions"), .target(name: "Buildable"), .target(name: "KeyPathConstraints") ] )
// Products define the executables and libraries a package produces, and make them visible to other packages. .library( name: "ExampleLogger", targets: ["ExampleLogger"]), ], dependencies: [ .package(name: "Utilities", path: "../Utilities"), ], 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 this package depends on. .target( name: "ExampleLogger", dependencies: [ .product(name: "Extensions", package: "Utilities", condition: .none), .product(name: "Buildable", package: "Utilities", condition: .none) ]), .testTarget( name: "ExampleLoggerTests", dependencies: ["ExampleLogger"]), ] ) Buildable only
// Products define the executables and libraries a package produces, and make them visible to other packages. .library( name: "ExampleLogger", targets: ["ExampleLogger"]), ], dependencies: [ .package(name: "Utilities", path: "../Utilities"), ], 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 this package depends on. .target( name: "ExampleLogger", dependencies: [ .product(name: "Extensions", package: "Utilities", condition: .none), .product(name: "BuilderHelper", package: "Utilities", condition: .none) ]), .testTarget( name: "ExampleLoggerTests", dependencies: ["ExampleLogger"]), ] ) Buildable + KeyPathConstraints
{ /// - Parameters: /// - context: Provides information about the package for which the plugin is invoked, /// as well as contextual information based on the plugin's stated intent /// and requirements. /// - arguments: arguments func performCommand( context: PackagePlugin.PluginContext, arguments: [String] ) async throws { //... } } source code formatting
{ /// - Parameters: /// - context:You can get some information about the package to which the plugin is being /// applied, pluginWorkDirectory, and a named command line executable tool /// - target: some information of the current target (name, directory, dependencies) /// - Returns: command to run during the build, you can return the build and prebuild /// commands here func createBuildCommands( context: PackagePlugin.PluginContext, target: PackagePlugin.Target ) async throws -> [PackagePlugin.Command] { // ... } }
ned set of outputs. • Re-run when outputs are missing or inputs change • Pre-build command • Don't have a clear set of outputs • Runs at the start of every build • Be careful about doing expensive work in it.