Using Live Issues and Fix-it - dummies

By Neal Goldstein, Dave Wilson

The Apple LLVM compiler engine wants to be your best friend, so Live Issues continuously evaluates your code in the background and alerts you to coding mistakes. Before this feature came along, you had to build your app first; this new way saves lots of time and effort.

But not only is Live Issues happy to point out your mistakes, Fix-it will also offer (when it can) to fix the problem for you. Clicking the error displays the available Fix-its, such as correcting an assignment to a comparison, repairing a misspelled symbol, or appending a missing semicolon.

With a single keyboard shortcut, you can instantly have the error repaired, and you can continue coding. Fix-it marks syntax errors with a red underline or a caret at the position of the error and with a symbol in the gutter.

For example, in the figure, the semicolon is missing after the [super viewDidLoad] statement. (Notice the error indicator — the red circle with exclamation point — in the Activity viewer, your Go To place for showing status messages, build progress, and errors.) Pressing Return will automatically fix this problem. This is a very useful feature and will cut down your debugging time significantly (especially if you actually use it).

Using Fix-it to fix a bug in an app.

Although Xcode and the compiler working together are very good at giving you warnings and errors, sometimes they’re a little slow on the uptake when you actually get around to fixing the problem. So don’t be surprised by random warnings and errors, especially if the compiler for some reason can’t find the header file.

If you see a warning or error that you’re just sure you’ve fixed, you can click the Run button. Xcode and the compiler will reset, and the warning will go away. (Unless, of course, it was right all along and you hadn’t fixed the problem.)