Minor Changes in Xcode 7.3 and Swift 2.2
So now that we’re in a post-Xcode 7.3 / Swift 2.2 world, I’m going through our past projects and seeing what needs tweaking.  So far Xcode’s suggested “Fix-It” prompt cleans up nearly everything I’ve come across*. And even if you do nothing, every project I’ve checked so far still builds fine. Yee-haw (kicks heels).  Just a lot yellow warnings, no red errors.  So if you’re working on something and suddenly, get a yellow warning, you can probably just let it mellow. Or let Xcode fix it.
So far here’s what I’ve encountered in a wide range of Sprite Kit projects….
What you’ll read…
C-style for statement is deprecated and will be removed in a future version of Swift
What you’ll see…
What to do….
Let Xcode fix it. For example…
for ( var i:Int = 0;Â i < 100; Â i++)
would now be…
for i:Int in 0 ..< 100
or even simpler….
for i in 0 … 99
I know, its SO cute now huh. Â Its like an emoji version of a for statement.
*Footnote
If Xcode leaves in the parenthesis from the original for statement, just take those out.
What you’ll read…
Use of string literal for Objective-C selectors is deprecated; use ‘#selector’ instead
What you’ll see…
Is something like this…
What to do….
Let Xcode fix it. For example, this snippet…
selector: “playBackgroundSound:”
would now be…
selector: #selector(GameViewController.playBackgroundSound(_:))
*Another footnoteÂ
Xcode 7.3 / Swift 2.2 clearly wanted to update the selectors for gesture recognizer targets, but just couldn’t quite close the deal. Granted,  I only noticed this happening some of the time Xcode auto-updated gesture recognizer targets.  So for example, it updated the code from this…
panRec.addTarget(self, action:”panned:”)
to this…
panRec.addTarget(self, action: Selector(“panned:”))
but really it should be this…
panRec.addTarget(self, action: #selector(Page.panned(_:) ))
The project builds fine either way (as it has so far with every un-updated line of code I’ve come across) but the warning is still there with the gesture recognizer targets.