Search code examples
xcodejenkinsoclint

oclint compile_commands.json not found at current location


Recently I'm trying to use Jenkins for Oclint statically analyzing objective-c sources.

So I followed the guide on the Oclint.org, especially this page oclint_guide_with_Jenkins

And then, I run the build job on the Jenkins. But the job was always failed with below logs. (Extra logs were just about svn check-out)

+ oclint-json-compilation-database -- -report-type pmd -o oclint.xml -rc=LONG_LINE=120
Error: compile_commands.json not found at current location.

Can anyone show me the way to solve this problem? :)


Solution

  • You need to generate the compile_commands.json , I am not sure if xcodebuild can do that , but you can use Facebook's xctool : https://github.com/facebook/xctool which is a wrapper over xcodebuild and provides different reporters.

    You can use Homebrew to install xctool as well, once install use the following commands to generate compile_commands.json and then run the oclint command.

    If you have a workspace file :

    xctool -scheme $scheme -workspace $workspaceFile -sdk iphonesimulator ARCHS=i386   VALID_ARCHS=i386 CURRENT_ARCH=i386 ONLY_ACTIVE_ARCH=NO -reporter json-compilation-database:compile_commands.json build
    

    If you have project file :

    xctool -scheme $scheme -project $projectFile -sdk iphonesimulator ARCHS=i386 VALID_ARCHS=i386   CURRENT_ARCH=i386 ONLY_ACTIVE_ARCH=NO -reporter json-compilation-database:compile_commands.json build