Werror or GTFO
There are a few useful warnings that should be set in any Xcode project. Here them, and why you should care:
- Mismatched Return Type Warns if a function does not declare a return type, or if the return type is not
void, but areturnstatement is found without a return value. - Sign Comparison You have a signed and and unsigned comparision. This warn will let you know if the result is incorrect after the signed get’s convertd to unsigned.
- Undeclared Selector Checks if the
@selectorconstruct makes reference to an undeclared selector. Let’s say you are handling a notification with a method you are referring to the@selectorexpression. Later on, you change the signature of the method. Unless you set this alarm, the code will be unaware of this change until runtime, when is already too late, and the app crash. - Treat Warning as Errors aka:
WerrorIn many other platforms, warnings are not that important. That’s not the case with Cocoa. Here a warning should be treated as an error, because most of the times, is just an error waiting to happens. - Run Static Analyzer The clang static analyzer is the best thing that happens to humanity ever. Well, ok, perhaps there is a little hyperbole here. But in any case, is always an excellent idea to run early, to run often this tool.