{"id":36,"date":"2012-06-29T17:34:13","date_gmt":"2012-06-29T15:34:13","guid":{"rendered":"http:\/\/andras.palfi.hu.rose.arvixe.com\/?p=36"},"modified":"2012-06-29T17:34:13","modified_gmt":"2012-06-29T15:34:13","slug":"objc-advanced-static-code-analyzer","status":"publish","type":"post","link":"https:\/\/andras.palfi.hu\/?p=36","title":{"rendered":"ObjC advanced static code analyzer"},"content":{"rendered":"<p>\t\t\t\tThere is a built in code analyzer in Xcode but unfortunately it&#8217;s not that we really need. It doesn&#8217;t check complexity, method sizes etc.<\/p>\n<p>This was one of the missing features till now because fortunately there is a good one out already: <a href=\"http:\/\/oclint.org\/\">OCLint (http:\/\/oclint.org\/)<\/a><\/p>\n<p>Unfortunately there is still no correct Xcode project file read support in it, but there is a dirty solution by recursively read all the .m files in a folder. On the developer&#8217;s site there is a basic script for it. Since it was a bit old I updated the script and now works well with the latest Xcode.<\/p>\n<p>Just put the following script into a .sh file and run in the root folder of the project (check the paths before run)<\/p>\n<pre class=\"lang:sh decode:true\" title=\"OCLint runner script\">#! \/bin\/bash\n\nLANGUAGE=objective-c\nARCH=armv7\nSYSROOT=\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/SDKs\/iPhoneOS5.0.sdk\nCLANG_INCLUDE=\/Applications\/Xcode.app\/Contents\/Developer\/Toolchains\/XcodeDefault.xctoolchain\/usr\/lib\/clang\/3.1\/include\nPCH_PATH=target-Prefix.pch\nFRAMEWORKS='\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/SDKs\/iPhoneOS5.1.sdk\/System\/Library\/Frameworks\/'\n\nINCLUDES='-I \/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/SDKs\/iPhoneOS5.1.sdk\/usr\/include'\nfor folder in `find . -type d`\ndo\n  INCLUDES=\"$INCLUDES -I $folder\"\ndone\n\nFILES=''\nfor file in `find . -name \"*.m\"`\ndo\n  FILES=\"$FILES $file\"\ndone\n\noclint -x $LANGUAGE -arch $ARCH -isysroot=$SYSROOT -F $FRAMEWORKS -I $CLANG_INCLUDE $INCLUDES $FILES<\/pre>\n<p>&nbsp;\t\t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There is a built in code analyzer in Xcode but unfortunately it&#8217;s not that we really need. It doesn&#8217;t check complexity, method sizes etc. This was one of the missing features till now because fortunately there is a good one out already: OCLint (http:\/\/oclint.org\/) Unfortunately there is still no correct Xcode project file read support [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"hide_page_title":"","footnotes":""},"categories":[3,4,13],"tags":[],"_links":{"self":[{"href":"https:\/\/andras.palfi.hu\/index.php?rest_route=\/wp\/v2\/posts\/36"}],"collection":[{"href":"https:\/\/andras.palfi.hu\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/andras.palfi.hu\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/andras.palfi.hu\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/andras.palfi.hu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=36"}],"version-history":[{"count":0,"href":"https:\/\/andras.palfi.hu\/index.php?rest_route=\/wp\/v2\/posts\/36\/revisions"}],"wp:attachment":[{"href":"https:\/\/andras.palfi.hu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=36"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/andras.palfi.hu\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=36"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/andras.palfi.hu\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=36"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}