import PackagePlugin // This example configures `swiftgen` to write to a "SwiftGenOutputs" directory. let generatedSourcesDir = targetBuildContext.outputDir.appending("SwiftGenOutputs") commandConstructor.addPrebuildGeneratedSourceDirectory(generatedSourcesDir) // Create a command to run `swiftgen` as a prebuild command. It will be run before // every build and generates source files into an output directory provided by the // build context. commandConstructor.addCommand( displayName: "Running SwiftGen", executable: try targetBuildContext.lookupTool(named: "swiftgen"), arguments: [ "config", "run", "--config", "\(targetBuildContext.packageDir.appending("swiftgen.yml"))" ], environment: [ "PROJECT_DIR": "\(targetBuildContext.packageDir)", "TARGET_NAME": "\(targetBuildContext.targetName)", "DERIVED_SOURCES_DIR": "\(generatedSourcesDir)", ] )