Using OCLint in Xcode
This document shows one solution of using OCLint to analyze the code quality of a Xcode project.
Background¶
This idea was originally posted in this blog. We hope to share it with more developers, and hope to motivate more ideas.
Setting up Target¶
- Add a new target in the project, and choose
Aggregate
as the template.
- Name the new target, here we simply call it “OCLint”, you could have more than one targets that focus on different aspects of the code analysis.
- Add a new build phase in the target we just created. Choose
And Run Script
for the phase type.
- In the script editor, we could enter the script which does the real work. We can also modify the script from this very generic version and its folks. We may need to change the
xcodebuild
options to use a particular scheme or target. In addition, based on the discussions we had, we can decide whether to useclean
anddry run
features. - For
xctool
users, the script can be largely simplified to something like this. - For
xcpretty
users, the script is also much simplier, check it out from this gist.
Running Analysis¶
- Choose the correct build scheme, here we choose
OCLint
.
- Click to build, or use the shortcut
Command+B
. - When the progress bar scrolls to the very right, the analysis is done, then we can check out the analysis results same as compile warnings.
OCLint 0.10.2 Documentation is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Maintained by Ryuichi Saito. Created using Sphinx 1.3.1.