I am trying to integrate OCLint 0.13 to check lint violations in my ObjC based iOS project.
As per this guide I created an aggregate target in Xcode to run a xcodebuild clean build
followed by oclint-xcodebuild
to generate a compile_commands.json
. I am able to run the clang
command from the generated compile_commands.json
file. However, in html report generated by oclint-json-compilation-database
command, while processing file like NEORepos/Public/ResourceObservables/NEOAggregatedObservable.h
, I see compiler errors like 'NEOObservables/NEOObservable.h' file not found
even though the said header file is present at NEOObservables/Public/Observables/NEOObservable.h
.
How can I get rid of these compiler errors which are preventing some of my source files from being linted?
Running the clang command from compile_commands.json
generates the .o
file, but OCLint doesn't seem to be able to compile using the json file.
I also tried adding a few more -I
include paths, but it didn't help. All suggestions and pointers are welcome.
Here's a piece of (edited) log...
xcode_clean_build_command = xcodebuild -workspace 'Neo.xcworkspace' -scheme 'NeoSampleApp' -configuration 'Debug' clean build -dry-run -derivedDataPath /Users/username/Documents/git/ios-neo_linter/build/Neo -sdk iphonesimulator CLANG_ENABLE_MODULE_DEBUGGING=NO CODE_SIGNING_ALLOWED=NO CODE_SIGN_IDENTITY='' CODE_SIGNING_REQUIRED=NO ENABLE_BITCODE=NO COMPILER_INDEX_STORE_ENABLE=NO | tee xcodebuild.log
...
/oclint-xcodebuild
...
Generating the compile_commands.json ...
Picking NEORepos/Public/ResourceObservables/NEOAggregatedObservable.m Picking NeoSampleApp/main.m
...
Shortlisted files for linting (2 out of 283) and creating a new compile_commands.json
...
Compiling /Users/username/Documents/git/ios-neo_linter/NEORepos/Public/ResourceObservables/NEOAggregatedObservable.m - Failed Compiling /Users/username/Documents/git/ios-neo_linter/NeoSampleApp/main.m - Success Analyzing /Users/username/Documents/git/ios-neo_linter/NeoSampleApp/main.m - Done
...
Generating lint report (if any)...
...
Executing command: oclint-json-compilation-database -e Pods -v -- -list-enabled-rules -no-analytics -enable-global-analysis -verbose --report-type html -o oclint.html -extra-arg=-Wno-everything
...
/usr/local/bin/oclint -p /Users/username/Documents/git/ios-neo_linter -list-enabled-rules -no-analytics -enable-global-analysis -verbose --report-type html -o oclint.html -extra-arg=-Wno-everything /Users/username/Documents/git/ios-neo_linter/NEORepos/Public/ResourceObservables/NEOAggregatedObservable.m /Users/username/Documents/git/ios-neo_linter/NeoSampleApp/main.m
The compiler error was due to the -dry-run
flag that I was using. Since it was doing a dry run, it was not creating .hmap
files that were needed (at least not in the right location) leading to <blah>.h file not found
errors.
However, without -dry-run
I would have to do a full build which is not acceptable for me. Will update if I find a solution with optimal performance.