How can I mark "To Do" comments in Xcode?
XcodeXcode Problem Overview
Currently I'm working on an iOS based Image Manipulation task.
###Problem:
I'm working on different modules. So If I need to add something in a module in future, I want to mark it as a To do note.
Are there any other macros or similar to add a to do note in Xcode ?
###I tried:
For this currently I'm using #pragma
like:
#pragma mark -
#pragma mark To do: Add the Image processing methods.
###I got: But it lists in the Method section like:
###What I actually need: The issue is, it's listed under the methods list so sometimes I forgot to remove this from the section also it's very difficult to find it in entire source code. (Searching #pragma results to show entire lists)
###Technical Details: I'm using Xcode Version 4.6.2 .
Xcode Solutions
Solution 1 - Xcode
I got it.
Writing comment like:
// TODO: Do something
Will do the trick.
I got something like:
Also there is a lot of options like:
// FIXME: Midhun
// ???: Midhun
// !!!: Midhun
// MARK: Midhun
Solution 2 - Xcode
// TODO: the thing todo
Is how you show todo tasks.
Solution 3 - Xcode
Using the
//TODO: some thing here
works if all you want to do is to look at the list of todos in the drop down
If you want to be intrusive you can use #warning
marks instead:
#warning this will create a compiler warning.
And when you build the app you will get a compiler warning (a yellow triangle, not a compiler error) which is a little more "in your face" about reminding you of things you need to do.
Solution 4 - Xcode
With the script below your can see all required tags like warnings.
-
Select your project in the Project Navigator
-
Open the target in the sidebar and move to the "Build Phases" tab
-
Click on "+" sign
-
Select "New Run Script Build Phase"
-
Add below script to "Run Script" The script:
KEYWORDS="TODO:|FIXME:|DevTeam:|XXX:" find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/ warning: \$1/"
Original answer was taken from Here
Another alternative is XToDo plugin for Xcode.
Solution 5 - Xcode
You can use XToDo plugin
https://github.com/trawor/XToDo
use ctrl+t to trigger the List Window on/off
Easy install with alcatraz use ctrl+t to trigger the List Window on/off
Solution 6 - Xcode
I started with
> // TODO: Implement bubble sort
.
Then I joined a large project and sometimes I needed a todo to live longer than a WIP commit and so to distinguish my todos from my peers I name spaced my todo with my initials:
> // TODO: SM: Implement bubble sort
Sometimes I wanted more visibility so I started to use pragma warnings in some places.
> #warning Implement bubble sort
One day I decided to turn on hard mode by adding -Werror
to my cflags. Unfortunately this makes pragma warnings useless because they prevent compilation. And so I went back to using // TODO:
until Jeff Nadeau told me that I can put
> -Wno-error=#warnings
in my cflags so as to not treat pragma warnings as errors. So now #warning
and -Werror
can live along side each other.
Solution 7 - Xcode
I tend to write exactly:
//TODO: Blah blah blah
Then I just do a COMMAND-SHIFT-F and look for "//TODO".
Using the file outline drop down will only show you TODOs for the current file, but I tend to want to see my project's TODO status.
Rough solution, but it does it's job.
Solution 8 - Xcode
I split up the recognized tokens into Warnings and Errors for my own use, thought I would share it here:
KEYWORDS="STUB:|WARNING:|TODO:|FIXME:|DevTeam:|\?\?\?:"
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -not -path "${SRCROOT}/Pods/*" -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/1: warning: \$1/"
KEYWORDS="ERROR:|XXX:|\!\!\!:"
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -not -path "${SRCROOT}/Pods/*" -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/1: error: \$1/"
ERROR_OUTPUT=`find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -not -path "${SRCROOT}/Pods/*" -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/1: error: \$1/"`
exit ${#ERROR_OUTPUT}
Solution 9 - Xcode
Another simple method, slightly outside the box, if you don't want to clutter up the methods listing bar, is to use a convention within comments like //Todo:
and when you want to address them en-masse, simply select the Find Navigator, match case and search for //Todo:
I prefer this as I don't like the methods drop down looking like spagetti-code. And yes, I often have lots of Todo:'s ;)
Solution 10 - Xcode
#error
and
#warning
are also used in C programming