Get ready for Swift 3.0 -Remove of ++ -- and C style for loops across a project

You've just installed XCode 7.3 with Swift 2.2... and now you are getting lots of warnings that ++, -- and their close friend the C-style for loop. The Swift team have done a great job of ensuring that you can click on the little yellow triangles and have XCode fix the problem. 

One at a time.

Eurgh

So I got to thinking... XCode has a great "Find and Replace in Project" feature... 

This not only lets you do your traditional style find and replace...

But also you can click on the Text in Replace > Text and select Regular Expression... This will let you use a regular expression to match, and a replacement pattern too. Even better, the Preview button will show you all the matches, and the proposed replacements. You can apply them all, or turn one or two off if they didn't work on a more complex case. 

I've set up a GitHub repo with a README that has a collection of useful patterns and templates you can just copy and paste in. Here's an example for replacing pretty standard C-style for loops. 

I've had a slightly quirky experience with making sure it generates the preview. But if you click on the scope button (in blue in the screen shot above), and then on your project (rather than my temporary deleteme.xcodeproj) it will generate an initial set of matches

You can now click on preview and see what has matched, and what it will be replaced with. You can slide the sliders in the middle to either leave each instance unchanged, or make the replacement.  

That's it. Really quick and easy updates of even the largest projects. See full the list here.

I've tried to cover most cases with the regular expressions and replacements in the GitHub repo, but PLEASE CONTRIBUTE PULL REQUESTS if you have an optimisation or a new suggestion. We have a few months to get in shape for the change and it would be fantastic to have a great community repository that would get people up and running quickly.