I am trying some simple code, which I found on natashatherobot.com.
var str = "Hello, playground"
let rangeOfHello = Range(start: str.startIndex, end: advance(str.startIndex, 5))
let helloStr = str.substringWithRange(rangeOfHello)
return helloStr
It works fine when I try it in Playgrounds:

But when I try using it in my Xcode project it gives me a compilation error:

Any ideas why this is happening?