// swift-tools-version:5.9 import CompilerPluginSupport import PackageDescription let swiftFeatures: [SwiftSetting] = [ .enableUpcomingFeature("ExistentialAny") ] let swiftLintPluginDependencies: [Target.Dependency] #if os(macOS) swiftLintPluginDependencies = [.target(name: "SwiftLintBinary")] #else swiftLintPluginDependencies = [.target(name: "swiftlint")] #endif let package = Package( name: "SwiftLint", platforms: [.macOS(.v12)], products: [ .executable(name: "swiftlint", targets: ["swiftlint"]), .library(name: "SwiftLintFramework", targets: ["SwiftLintFramework"]), .plugin(name: "SwiftLintBuildToolPlugin", targets: ["SwiftLintBuildToolPlugin"]), .plugin(name: "SwiftLintCommandPlugin", targets: ["SwiftLintCommandPlugin"]) ], dependencies: [ .package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.2.1"), .package(url: "https://github.com/apple/swift-syntax.git", from: "510.0.2"), .package(url: "https://github.com/jpsim/SourceKitten.git", .upToNextMinor(from: "0.35.0")), .package(url: "https://github.com/jpsim/Yams.git", from: "5.0.6"), .package(url: "https://github.com/scottrhoyt/SwiftyTextTable.git", from: "0.9.0"), .package(url: "https://github.com/JohnSundell/CollectionConcurrencyKit.git", from: "0.2.0"), .package(url: "https://github.com/krzyzanowskim/CryptoSwift.git", .upToNextMinor(from: "1.8.0")) ], targets: [ .plugin( name: "SwiftLintBuildToolPlugin", capability: .buildTool(), dependencies: swiftLintPluginDependencies ), .plugin( name: "SwiftLintCommandPlugin", capability: .command(intent: .custom(verb: "swiftlint", description: "SwiftLint Command Plugin")), dependencies: swiftLintPluginDependencies ), .executableTarget( name: "swiftlint", dependencies: [ .product(name: "ArgumentParser", package: "swift-argument-parser"), "CollectionConcurrencyKit", "SwiftLintFramework", "SwiftyTextTable", ], swiftSettings: swiftFeatures ), .testTarget( name: "CLITests", dependencies: [ "swiftlint" ], swiftSettings: swiftFeatures ), .target( name: "SwiftLintCore", dependencies: [ .product(name: "CryptoSwift", package: "CryptoSwift", condition: .when(platforms: [.linux])), .target(name: "DyldWarningWorkaround", condition: .when(platforms: [.macOS])), .product(name: "SourceKittenFramework", package: "SourceKitten"), .product(name: "SwiftIDEUtils", package: "swift-syntax"), .product(name: "SwiftOperators", package: "swift-syntax"), .product(name: "SwiftParser", package: "swift-syntax"), .product(name: "SwiftSyntax", package: "swift-syntax"), .product(name: "SwiftSyntaxBuilder", package: "swift-syntax"), .product(name: "SwiftyTextTable", package: "SwiftyTextTable"), .product(name: "Yams", package: "Yams"), "SwiftLintCoreMacros" ], swiftSettings: swiftFeatures ), .target( name: "SwiftLintBuiltInRules", dependencies: ["SwiftLintCore"], swiftSettings: swiftFeatures ), .target( name: "SwiftLintExtraRules", dependencies: ["SwiftLintCore"] ), .target( name: "SwiftLintFramework", dependencies: [ "SwiftLintBuiltInRules", "SwiftLintCore", "SwiftLintExtraRules", // Workaround for https://github.com/apple/swift-package-manager/issues/6940: .product(name: "ArgumentParser", package: "swift-argument-parser"), "CollectionConcurrencyKit" ], swiftSettings: swiftFeatures ), .target(name: "DyldWarningWorkaround"), .target( name: "SwiftLintTestHelpers", dependencies: [ "SwiftLintFramework" ], path: "Tests/SwiftLintTestHelpers" ), .testTarget( name: "SwiftLintFrameworkTests", dependencies: [ "SwiftLintFramework", "SwiftLintTestHelpers", "SwiftLintCoreMacros" ], exclude: [ "Resources", ], swiftSettings: swiftFeatures ), .testTarget( name: "GeneratedTests", dependencies: [ "SwiftLintFramework", "SwiftLintTestHelpers" ], swiftSettings: swiftFeatures ), .testTarget( name: "IntegrationTests", dependencies: [ "SwiftLintFramework", "SwiftLintTestHelpers" ], exclude: [ "default_rule_configurations.yml" ], swiftSettings: swiftFeatures ), .testTarget( name: "ExtraRulesTests", dependencies: [ "SwiftLintFramework", "SwiftLintTestHelpers" ] ), .macro( name: "SwiftLintCoreMacros", dependencies: [ .product(name: "SwiftSyntaxMacros", package: "swift-syntax"), .product(name: "SwiftCompilerPlugin", package: "swift-syntax") ], path: "Source/SwiftLintCoreMacros", swiftSettings: swiftFeatures ), .testTarget( name: "MacroTests", dependencies: [ "SwiftLintCoreMacros", .product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax"), ], swiftSettings: swiftFeatures ), ] ) #if os(macOS) package.targets.append( .binaryTarget( name: "SwiftLintBinary", url: "https://github.com/realm/SwiftLint/releases/download/0.55.1/SwiftLintBinary-macos.artifactbundle.zip", checksum: "722a705de1cf4e0e07f2b7d2f9f631f3a8b2635a0c84cce99f9677b38aa4a1d6" ) ) #endif