On my work, technology and related stuff....

No comments

As an iOS developer (or any developer for that matter), it is not uncommon (or dare I say- its “very common”) for us to defer things while coding so as to not disrupt the current coding flow. For instance, handling of a special case or updating an algorithm with a more efficient one or just a reminder to double check a certain logic . To remind ourselves, we typically include a comment like “ToDo: Handle error code -1020” in our code.

 

Now, before we realize it, we have several “ToDos” and “FixMe” scattered throughout our project and unfortunately, many of them go unattended . Note that “attending” to them may be as simple as removing the comment because we have in fact handled the “To Do” but have just forgotten to remove the now obsolete comment which leads to clutter and confusing code.

 
 

So here is a neat little perl script that I found (and tweaked a wee bit for my purpose) that solves the problem. The script is executed  every time my project is built. The purpose of script is simple. The script greps for keywords in all the .h and .m files in the  ${SRCROOT} folder and prefixes it with a “warning”  label.

 

Now, every time, I compile my project, the script runs and displays all statements that begin with keywords listed in the KEYWORDS reg expression show up as warnings. They are now hard to miss and I can ensure that all the “To Do”s are handled in a timely manner.

To add the script, select “Add Build Phase” under the “Build Phases” tab of Xcode project settings.

 

Then , cut and paste the script to the “Run Script” section


Now, when you build your app, you should see all comments that include the keywords mentioned in the script listed as warnings.

Tags: , , , , , , , ,

Leave a Reply

*