Xcode - Quickly fix the fixable errors

Today I am going to write about a neat trick I learned about automatically fixing fixable error in Xcode.

We usually come across the error which are easily fixable. These include typo'ed method/parameter names, missing semicolons, failure to close brackets. Speaking of Swift, they are also errors when we create a let variables and try to modify their value. In this case they are easily fixable by switching let to var.

Swift

swift_fixable_error

Objective-C

objectivec_fixable_error

However, it's tedious when there are bunch of such fixable errors scattered throughout the file and frustration increases exponentially with number of such error and warnings.

However, if you trust Xcode enough, you can simply follow this shortcut to to automatically fix fixable warnings.

control + option + command + F or Control ⌃ + Option ⌥ + Command ⌘ + F. This will fix all the fixable errors in current scope.

fix_fixable_errors_option_menu

This might sound like too much for normal project, but look at it as if you have project with thousands of LOC. Especially when new version of Swift launches. (As in transition from Swift 1.0 to 2.0). You get bunch of warnings and errors with fixable alternative. You don't want to click on right red dot every time to fix obvious error/warning. You can fix it in a moment either with an editor option or using a shortcut key.