1.下载包
参考地址https://github.com/Backelite/sonar-swift
<1>a Mac with Xcode 7 or +
<2>下载SonarQube and SonarQube Scanner 8.0版本的JAVA环境是JAVA11
将https://github.com/Backelite/sonar-swift/releases 下载的插件放入下载的SonarQube的插件目录中,如图
在SonarQube的目录结构中 执行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.配置环境
SonarQube Scanner下载之后配置环境
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
执行sonar-scanner -h 是否安装成功(如果失败,重新安装sonar-scanner,配置好路径)
在项目的主目录中放置两个文件
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 根据项目名修改里面的参数 //https://raw.githubusercontent.com/Backelite/sonar-swift/master/sonar-project.properties