手順
- リポジトリのREADMEの通り実行していく
- ルートフォルダに
.swiftlint.yml
を追加 - また
Package.swift
に下記の依存関係を追加
.package(url: "https://github.com/SimplyDanny/SwiftLintPlugins", from: "<version>")
- またTargets毎に下記を追加
Swift Package Projects
Build tool plugins run when building each target. When a project has multiple targets, the plugin must be added to the desired targets individually.To do this, add the plugin to the target(s) to be linted as follows:
.target(
...
plugins: [.plugin(name: "SwiftLintBuildToolPlugin", package: "SwiftLintPlugins")]
),
- またSwiftLintのプラグインに最低OSの制限があり、ビルドエラーになるので最低OSの設定を追加
platforms: [
.iOS(.v17),
.macOS(.v15)
],
- まとめると以下の通りです
// swift-tools-version: 6.1
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "IKEHGitHubAPIClient",
platforms: [
.iOS(.v17),
.macOS(.v15)
],
products: [
// Products define the executables and libraries a package produces, making them visible to other packages.
.library(
name: "IKEHGitHubAPIClient",
targets: ["IKEHGitHubAPIClient"]),
],
dependencies: [
.package(url: "https://github.com/SimplyDanny/SwiftLintPlugins", from: "0.1.0")
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.target(
name: "IKEHGitHubAPIClient",
dependencies: [],
plugins: [
.plugin(name: "SwiftLintBuildToolPlugin", package: "SwiftLintPlugins")
],
),
.testTarget(
name: "IKEHGitHubAPIClientTests",
dependencies: ["IKEHGitHubAPIClient"],
plugins: [
.plugin(name: "SwiftLintBuildToolPlugin", package: "SwiftLintPlugins")
],
),
]
)
- 以上の設定を行い、ビルドして警告がでれば成功です!