|
| 1 | +// swift-tools-version:5.9 |
| 2 | + |
| 3 | +import PackageDescription |
| 4 | + |
| 5 | +let packageName = "Layout" |
| 6 | + |
| 7 | +enum SwiftLint { |
| 8 | + static let plugin = "SwiftLintPlugin-\(packageName)" |
| 9 | + static let binary = "SwiftLintBinary-\(packageName)" |
| 10 | +} |
| 11 | + |
| 12 | +let package = Package( |
| 13 | + name: packageName, |
| 14 | + platforms: [ |
| 15 | + .iOS(.v13), |
| 16 | + ], |
| 17 | + products: [ |
| 18 | + .library( |
| 19 | + name: "Layout", |
| 20 | + targets: ["Layout"]), |
| 21 | + ], |
| 22 | + dependencies: [ |
| 23 | + .package( |
| 24 | + url: "https://github.com/Quick/Nimble.git", |
| 25 | + from: "13.0.0"), |
| 26 | + .package( |
| 27 | + url: "https://github.com/pointfreeco/swift-snapshot-testing.git", |
| 28 | + from: "1.15.0"), |
| 29 | + ], |
| 30 | + targets: [ |
| 31 | + .target( |
| 32 | + name: "Layout", |
| 33 | + swiftSettings: .swiftSettings, |
| 34 | + plugins: [ |
| 35 | + .plugin(name: SwiftLint.plugin), |
| 36 | + ]), |
| 37 | + .testTarget( |
| 38 | + name: "LayoutTests", |
| 39 | + dependencies: [ |
| 40 | + "Layout", |
| 41 | + "Nimble", |
| 42 | + .product(name: "SnapshotTesting", package: "swift-snapshot-testing"), |
| 43 | + ], |
| 44 | + exclude: [ |
| 45 | + "__Snapshots__", |
| 46 | + "UIKit/__Snapshots__", |
| 47 | + ], |
| 48 | + swiftSettings: .swiftSettings, |
| 49 | + plugins: [ |
| 50 | + .plugin(name: SwiftLint.plugin), |
| 51 | + ]), |
| 52 | + .plugin( |
| 53 | + name: "SwiftLintCommand", |
| 54 | + capability: .command(intent: .custom(verb: "swiftlint", description: "SwiftLint Command Plugin")), |
| 55 | + dependencies: [ |
| 56 | + .target(name: SwiftLint.binary) |
| 57 | + ]), |
| 58 | + .plugin( |
| 59 | + name: SwiftLint.plugin, |
| 60 | + capability: .buildTool(), |
| 61 | + dependencies: [ |
| 62 | + .target(name: SwiftLint.binary) |
| 63 | + ], |
| 64 | + path: "Plugins/SwiftLintPlugin"), |
| 65 | + .binaryTarget( |
| 66 | + name: SwiftLint.binary, |
| 67 | + url: "https://github.com/realm/SwiftLint/releases/download/0.54.0/SwiftLintBinary-macos.artifactbundle.zip", |
| 68 | + checksum: "963121d6babf2bf5fd66a21ac9297e86d855cbc9d28322790646b88dceca00f1"), |
| 69 | + ] |
| 70 | +) |
| 71 | + |
| 72 | +extension Array where Element == SwiftSetting { |
| 73 | + |
| 74 | + static var swiftSettings: [SwiftSetting] { |
| 75 | + if let value: String = Context.environment["SWIFT_STRICT_CONCURRENCY"] { |
| 76 | + return [.unsafeFlags(["-strict-concurrency=\(value)"])] |
| 77 | + } else if Context.environment["SWIFT_EMIT_EXTENSION_BLOCK_SYMBOLS"] != nil { |
| 78 | + return [.unsafeFlags(["-emit-extension-block-symbols"])] |
| 79 | + } |
| 80 | + return [] |
| 81 | + } |
| 82 | +} |
0 commit comments