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).
  1. cp bin/oclint* /usr/local/bin/
  2. 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下通过xcodebuild使用oclint的更多相关文章

  1. Mac下安装最新版本的Graphviz

    由于版本兼容问题,Mac下Graphviz之前一直装的是低版本的2.36.高版本的安装方法如下: 1.log in & download Xcode an Xcode Command Line ...

  2. mac下cordova的ios-deploy安装问题

    mac下进行cordova项目编译部署到ios设备,这个时候需要安装ios-deploy,会失败: npm WARN lifecycle ios-deploy@1.8.6~preinstall: ca ...

  3. appium mac 下 安装及踩坑

    Appium Appium是一个开源.跨平台的测试框架,可以用来测试原生及混合的移动端应用.Appium支持IOS.Android及FirefoxOS平台.Appium使用WebDriver的json ...

  4. MAC 下将libpomelo连接到cocos2d-x

    摘要:借助GYP将libpomelo连接到Cocos2d-x项目并使项目能与服务端成功连接. 配置:OS X 10.9.4 + Xcode 6.0 + Cocos2d-x-3.2 一.部署GYP(Ge ...

  5. mac下安装及配置tomcat

    mac下的软件不像windows下的程序那样写注册表,对于tomcat的安装来说,在mac下是名符其实的绿色软件,具体操作如下: 1.到 apache官方主页 下载完整 tar.gz文件包.(没有专门 ...

  6. MAC下 mysql不能插入中文和中文乱码的问题总结

    MAC下 mysql不能插入中文和中文乱码的问题总结 前言 本文中所提到的问题解决方案,都是基于mac环境下的,但其他环境,比如windows应该也适用. 问题描述 本文解决下边两个问题: 往mysq ...

  7. 【开发软件】 在Mac下配置php开发环境:Apache+php+MySql

    本文地址 原文地址   本文提纲: 1. 启动Apache 2. 运行PHP 3. 配置Mysql 4. 使用PHPMyAdmin 5. 附录   有问题请先 看最后的附录   摘要: 系统OS X ...

  8. 2016年最新mac下vscode配置golang开发环境支持debug

    网上目前还找不到完整的mac下golang环境配置支持,本人配置成功,现在整理分享出来. mac最好装下xcode,好像有依赖关系安装Homebrew打开终端窗口, 粘贴脚本执行/usr/bin/ru ...

  9. 【工匠大道】Mac下Java开发环境配置简述

    本文地址 原文地址 分享提纲: 1. 下载JDK1.7 2. 配置java_home 3 .安装tomcat 4 .安装eclipse或者myeclipse 5.  mysql安装 破解版下载请参考M ...

随机推荐

  1. python 网络编程第四版

    使用SocketServer 模块来完成服务端编程 1.服务端代码如下: #!/usr/bin/python #!coding:utf-8 import SocketServer as sockets ...

  2. 在Linux上怎么安装和配置DenyHosts工具

    使用DenyHosts能够进行自动屏ip的功能,掌握DenyHosts在Linux系统中的安装是很有必要的,那么在Linux系统中要如何安装DenyHosts工具呢?安装后又要如何配置呢?这都是用户需 ...

  3. ISO,CD,iso9660

    audio CD与CD-ROM的区别? 1.CD Audio 利用PCM(Pulse Code Modulation)方式,将Analog信号转为Digital Data,并储存在Disc上. CD ...

  4. 利用boost做string到wstring转换,以及字符集转换 - Error - C++博客

    利用boost做string到wstring转换,以及字符集转换 - Error - C++博客 利用boost做string到wstring转换,以及字符集转换 #include <boost ...

  5. Debug, Release区别

    Debug, Release区别 Debug附加了很多调试信息,主要用于调试,所以文件大 Release就是经过优化的版本,去除了调试信息,进行了代码优化,所以文件较小,同时速度要快于Debug De ...

  6. 我的RTOS 之六 -- Touch移植(s5pv210+threadx+ucgui+touch)

    非常久没有关注RTOS了,所以也一直没有更新.近期闲了,把GPIO I2C调通了.简单移植了Touch.在S5PV210上使用. 调试I2C时.废了非常多周折,最后借助示波器才发现一个小小的错误.折腾 ...

  7. Quartz.NET 2.0 作业调度框架使用

    Quartz.NET是一个开源的作业调度框架,是 OpenSymphony 的 Quartz API 的.NET移植,它用C#写成,可用于winform和asp.net应用中.它提供了巨大的灵活性而不 ...

  8. CRM后期修改实体,新增货币类型字段 需要注意的问题

    货币类型字段新增 需要处理历史数据 否则编辑会报错 提示如果货币字段中存在值,则需要指定币种,请选择币种,然后重试 编辑时货币字段不显示¥符号.新增正常.第一次编辑提示错误保存后再编辑也正常.不是JS ...

  9. java 线程之间通信以及notify与notifyAll区别。

    jvm多个线程间的通信是通过 线程的锁.条件语句.以及wait().notify()/notifyAll组成. 下面来实现一个启用多个线程来循环的输出两个不同的语句. package com.app. ...

  10. Properties文件的XML格式(转)

    想必大家都用过*.properties文件,作为配置文件.但是,如果该文件写入了中文,待编译后内容就会成为乱码,使用native命令也好.使用ant执行编码转换也好,多少有点麻烦,与其如此,我们不如直 ...