|
| 1 | +// swift-tools-version: 6.1 |
| 2 | +// The swift-tools-version declares the minimum version of Swift required to build this package. |
| 3 | + |
| 4 | +import PackageDescription |
| 5 | +import CompilerPluginSupport |
| 6 | + |
| 7 | +let package = Package( |
| 8 | + name: "MacrosDemo", |
| 9 | + platforms: [.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6), .macCatalyst(.v13)], |
| 10 | + products: [ |
| 11 | + // Products define the executables and libraries a package produces, making them visible to other packages. |
| 12 | + .library( |
| 13 | + name: "MacrosDemo", |
| 14 | + targets: ["MacrosDemo"] |
| 15 | + ), |
| 16 | + .executable( |
| 17 | + name: "MacrosDemoClient", |
| 18 | + targets: ["MacrosDemoClient"] |
| 19 | + ), |
| 20 | + ], |
| 21 | + dependencies: [ |
| 22 | + .package(url: "https://github.com/swiftlang/swift-syntax.git", from: "600.0.0-latest"), |
| 23 | + ], |
| 24 | + targets: [ |
| 25 | + // Targets are the basic building blocks of a package, defining a module or a test suite. |
| 26 | + // Targets can depend on other targets in this package and products from dependencies. |
| 27 | + // Macro implementation that performs the source transformation of a macro. |
| 28 | + .macro( |
| 29 | + name: "MacrosDemoMacros", |
| 30 | + dependencies: [ |
| 31 | + .product(name: "SwiftSyntaxMacros", package: "swift-syntax"), |
| 32 | + .product(name: "SwiftCompilerPlugin", package: "swift-syntax") |
| 33 | + ] |
| 34 | + ), |
| 35 | + |
| 36 | + // Library that exposes a macro as part of its API, which is used in client programs. |
| 37 | + .target(name: "MacrosDemo", dependencies: ["MacrosDemoMacros"]), |
| 38 | + |
| 39 | + // A client of the library, which is able to use the macro in its own code. |
| 40 | + .executableTarget(name: "MacrosDemoClient", dependencies: ["MacrosDemo"]), |
| 41 | + |
| 42 | + // A test target used to develop the macro implementation. |
| 43 | + .testTarget( |
| 44 | + name: "MacrosDemoTests", |
| 45 | + dependencies: [ |
| 46 | + "MacrosDemoMacros", |
| 47 | + .product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax"), |
| 48 | + ] |
| 49 | + ), |
| 50 | + ] |
| 51 | +) |
0 commit comments