mac下通過xcodebuild使用oclint
step1 :下載oclint並安裝
下載地址: http://oclint.org/downloads.html
選擇mac os x或者darwin的包,下載到本地。
目錄類似下面:
oclint-release |-bin |-lib |---clang |-----3.4 |-------include |-------lib |---oclint |-----rules |-----reporters
安裝官方指南: http://docs.oclint.org/en/dev/intro/installation.html
我們此時在bash(終端terminal)中執行oclint會告訴我們命令找不到,我們需要把它的執行檔案路徑加入到環境變數或者把執行檔案拷貝到系統目錄。
方法1(推薦):把路徑加到環境變數中(實際是.bash_profile或者.bashrc檔案中,關於這兩者有不知道的同學可以搜尋之)
OCLINT_HOME=/path/to/oclint-release // /path/to/oclint-release 是執行檔案存放路徑,例如:/Users/xxx/Desktop/oclint-0.9.dev.a6ffa25 export PATH=$OCLINT_HOME/bin:$PATH
關於.bash_profile,mac系統裡本身可能不存在,建立和編輯的步驟見下文:
http://blog.csdn.net/openglnewbee/article/details/36663591
關於bashrc,位於/etc目錄下,使用command+shift+g 可以前往/etc,找到bashrc檔案修改許可權後可以編輯。
方法2:把執行檔案拷貝到系統目錄(請自行嘗試)
A few directories are supposed to be in the system PATH already, to mention a few, /usr/local/bin, /usr/bin, /bin, etc. Therefore, it’s also possible to copy the OCLint binaries into one of these folders, and move the dependencies over. As an example, presumes /usr/local/bin is in the PATH (may require root permission).
- cp bin/oclint* /usr/local/bin/
- cp -rp lib/* /usr/local/lib/
Dependency libraries are required to be put into appropriate directory, because oclint executable searches $(/path/to/bin/oclint)/../lib/clang, $(/path/to/bin/oclint)/../lib/oclint/rules and $(/path/to/bin/oclint)/../lib/oclint/reporters for builtin headers and dynamic libraries by default.
以上兩個方法執行完其中1個我們就可以說oclint已經安裝完成了,此時在bash中執行oclint應該得到如下提示:
oclint: Not enough positional command line arguments specified!
step 2:通過xcodebuild執行oclint命令
1.在bash中通過cd命令進到需要lint的工程路徑下
2.在bash中執行:xcodebuild | tee xcodebuild.log
(若工程中存在多個不同的target,按照如下格式輸入: xcodebuild -target selectedTargetName | tee xcodebuild.log,將需要跑的target名字填入到命令中 )
此命令呼叫xcodebuild進行了編譯並把相關日誌資訊輸入到xcodebuild.log,該log檔案是後續步驟的必要條件,生成在當前的工程目錄中.官方解釋如下:
We need to save the xcodebuild output to a log file, by convention, name it xcodebuild.log. We can use xcodebuild <options> | tee xcodebuild.log to pipe every line of the output to xcodebuild.log file.
3.在bash中執行 oclint-xcodebuild xcodebuild.log
此步驟是利用之前的.log檔案通過oclint-xcodebuild的可執行檔案生成了名為compile_commands.json的json格式檔案,該檔案應該包含了多組內容,其中的key分別為directory、command、file,該檔案不應該為空。此檔案是下一步輸入的必要條件。
4. 在bash中執行 oclint-json-compilation-database,此步驟是真正執行了lint,執行完應該在終端輸出結果。
若希望輸出報告到檔案中,執行如下命令:
oclint-json-compilation-database -- -o=report.html
官方參考指南:http://docs.oclint.org/en/dev/guide/xcodebuild.html
注意事項:
1.octool 0.7及以前的版本不支援xcode5.
2.在執行前注意執行clean,也可在step2中的第二步執行如下命令:
xcodebuild -dry-run | tee xcodebuild.log 說明如下:
If a source file has been built by xcodebuild, and it’s not been modified since last build, then it might not be compiled again when you invoke xcodebuild the second time. In other words, if it happens, this file won’t be shown in the log. So we won’t see it in the compile_commands.json. To avoid that, use clean build by removing all build products and intermediate files from the build directory.
However, cleaning and building the entire project takes longer time, especially for those big projects. In this case, if file structure hasn’t been changed, and build settings haven’t been modified, then it’s okay to keep the existing xcodebuild.log and compile_commands.json to save time.
If the xcodebuild build can be guaranteed to be successful with the options specified, then we could also use -dry-run option to build the project without actually running the commands, so that we can still capture the xcodebuild log but with reduced time.
相關文章
- Mac下通過Homebrew安裝MySQLMacMySql
- xcodebuild -workspace 情況下,部分坑的處理XCodeUI
- Mac下通過Apple Configurator 2獲取ipa包MacAPP
- myeclipse下通過maven建立springbootEclipseMavenSpring Boot
- 前端通過 post 下載檔案前端
- 優雅通過HttpClientFactory使用HttpClientHTTPclient
- 使用Laravel框架,怎麼通過訪問/xxxx/ooo.php也通過路由來使用Laravel框架PHP路由
- linux下通過原始碼安裝gitLinux原始碼Git
- Linux下如何通過命令連線wifiLinuxWiFi
- 通過ActionTrail監控AccessKey的使用AI
- 【Python】通過xlwt模組使用表格Python
- Redbox Mobile:海外市場使用者都是通過哪些渠道來下載App?APP
- OCLint 實現 Code Review - 給你的程式碼提提質量View
- 通過 React Hooks 宣告式地使用 setIntervalReactHook
- Mac 下使用homebrew安裝NVMMac
- 在Mac下使用Python3MacPython
- Mac下使用Docker開啟KubernetesMacDocker
- 通過自定義Istio Mixer Adapter在JWT場景下實現使用者封禁APTJWT
- 防火牆雙出口環境下私網使用者通過NAPT訪問Internet防火牆APT
- 終端報錯"xcrun: error: unable to find utility “xcodebuild”, not a developer tool orErrorXCodeUIDeveloper
- 【譯】如何通過 INUIAddVoiceShortcutButtonDelegate 正確地使用 INUIAddVoiceShortcutButtonUI
- 通過shell指令碼 批量新增使用者指令碼
- 記錄Mac下使用Charles抓包Mac
- 前端如何通過連結去下載img圖片前端
- Raft協議:通過TermId大的通過Raft協議
- Mac通過type-c介面無法識別行動硬碟Mac硬碟
- PyCharm使用技巧:通過DockerCompose配置遠端直譯器PyCharmDocker
- 使用Cilium增強Istio—通過Socket感知BPF程式
- 使用json通過telegraf生成metrics(摘自telegraf github文件)JSONGithub
- 使用 grpcurl 通過命令列訪問 gRPC 服務RPC命令列
- 006 通過連結串列學Rust之使用OptionRust
- window下通過Xshell登入GCP計算機例項GC計算機
- vue通過url下載檔案,直接預覽問題Vue
- 求助:環境正常,xcodebuild 也執行成功了,但是使用 appium desktop 的時候,出現:Could not start sessionXCodeUIAPPSession
- Mac Mojava 通過 homebrew 安裝 PHP5.6 版本正確姿勢MacJavaPHP
- Mac系統如何通過自帶的工具進行磁碟修復Mac
- mac下iterm2使用rz和sz上傳下載Mac
- 私網使用者通過Smart NAT 訪問Internet
- 使用Java通過POI讀取EXCEL中的資料JavaExcel