TWilly TWilly - 18 days ago 6
iOS Question

Quick way to fix XCode warnings

I've been switching between versions of Swift in XCode 6 and my project now has 220 warnings. Mostly minor code suggestions.

Is there an easy way in XCode to run through all the warnings and use the "Fix-it" tool to auto correct it?

I would like to review each warning, then click a button to fix the warning, and then skip to next warning. Otherwise it's going to take me a few hours to manually get through each warning.

Answer

Your best bet is to use keyboard shortcuts. The default keyboard shortcut for Navigate > Jump to Next Issue is ⌘' (command-single-quote). If you press it, Xcode will jump to the next issue it knows about. If that issue has a Fix-it available, the Fix-it popover will appear automatically and you can press return to execute the Fix-it, or press ⌘' to leave the code unchanged and go to the next issue, or press escape to leave the code unchanged and stay on that issue.

You can also open the Issue Navigator (default shortcut: ⌘4). Then you can click on issues one-by-one. If you click on an issue with a Fix-it, Xcode will show the Fix-it popover and you can press return to execute the Fix-it.