CocoaPodsでSwiftLintを導入する参考ページが少なかったので備忘録。
環境
Xcode 9.0
Swift 4.0
SwiftLintをインストール
Profileに以下のように記載して、「pod install」
(Profiileの例)
# Uncomment the next line to define a global platform for your project
# platform :ios, '11.0'
target 'rules-demo' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for rules-demo
pod 'SwiftLint'
target 'rules-demoTests' do
inherit! :search_paths
# Pods for testing
end
end
インストール後の設定

上図の赤枠に以下のテキストをコピペする。
※Homebrewでインストールした場合とテキストが異なるので注意!
if which "${PODS_ROOT}/SwiftLint/swiftlint" >/dev/null; then
${PODS_ROOT}/SwiftLint/swiftlint
else
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi
動作確認
⌘+Bで、Bulidをしてください。
SwiftLintの動作確認が出来ましたら、これで導入は終わりです!