1.下載包
參考地址https://github.com/Backelite/sonar-swift
<1>a Mac with Xcode 7 or +
<2>下載SonarQube?and?SonarQube Scanner? 8.0版本的JAVA環(huán)境是JAVA11
將https://github.com/Backelite/sonar-swift/releases?下載的插件放入下載的SonarQube的插件目錄中,如圖
在SonarQube的目錄結(jié)構(gòu)中 執(zhí)行SonarQube?/usr/local/sonarqube-8.0/bin/macosx-universal-64/sonar.sh? console
<3>xcpretty?(see instructions below)
<4>SwiftLint?(HomeBrew?installed and?brew install swiftlint). Version 0.3.0 or above.
<5>SwiftLint?(HomeBrew?installed and?brew install swiftlint). Version 0.3.0 or above.
<6>slather?(gem install slather). Version 2.1.0 or above (2.4 since Xcode 8.3).
<7>?lizard?(PIP?installed and?sudo pip install lizard)
<8>OCLint?installed. Version 0.11.0 recommended (0.13.0 since Xcode 9).
2.配置環(huán)境
SonarQube Scanner下載之后配置環(huán)境
open ~/.bash_profile?
export JAVA_HOME=/Library/Java/JavaVirtualMachines/?jdk-11.0.5.jdk/Contents/Home
PATH=$JAVA_HOME/bin:$PATH
export SONAR_HOME=/usr/local/sonarqube-8.0
PATH=$SONAR_HOME/bin:$PATH
export SWIFTLINT=/usr/local/bin/swiftlint
PATH=$SWIFTLINT/bin:$PATH
export XCPRETTY=/usr/local/bin/xcpretty
PATH=$XCPRETTY/bin:$PATH
export SLATHER=/Users/tygps/.rvm/gems/ruby-2.6.3/bin/slather
PATH=$SLATHER/bin:$PATH
export TAILOR=/usr/local/bin/tailor
PATH=$TAILOR/bin:$PATH
export LIZARD=/usr/local/bin/lizard
PATH=$LIZARD/bin:$PATH
export XCODEBUILD=/usr/bin/xcodebuild
PATH=$XCODEBUILD/bin:$PATH
alias python="/usr/local/bin/python3"
export PATH
export SONAR_SCANNER_HOME=/Users/tygps/Documents/sonar-scanner-4.2.0.1873-macosx// 下載的地址
export PATH=$PATH:$S
ONAR_SCANNER_HOME/bin
source ~/.bash_profile
執(zhí)行sonar-scanner -h 是否安裝成功(如果失敗,重新安裝sonar-scanner,配置好路徑)
在項(xiàng)目的主目錄中放置兩個文件?
run-sonar-swift.sh ?//https://raw.githubusercontent.com/Backelite/sonar-swift/master/sonar-swift-plugin/src/main/shell/run-sonar-swift.sh
sonar-project.properties ? 根據(jù)項(xiàng)目名修改里面的參數(shù) //https://raw.githubusercontent.com/Backelite/sonar-swift/master/sonar-project.properties