Swift in Xcode 6.1
In the lifecycle of any release there comes a time when known bugs are far better than unknown bugs you accidentally introduce. Obviously Apple has reached that point with iOS 8, the SDK, Xcode 6, and Swift. The version shipping in the Xcode 6 GM is certainly a good release for Swift, but did you know there is a newer version of the compiler available for download right now?
Download and install the Xcode 6.1 tools and you'll find these changes:
- A bunch more APIs have been audited for Optional conformance, so they return
T!. Good progress on this front.
- An initializer can fail by returning nil. Declare them
init?. The result is the constructor call then yields an
Optional<T>, letting the caller know the initializer may fail. (There is currently a bug that requires classes to initialize all stored properties even if the return value is a nil indicating failure.)
- Custom operators can now use the
- Enums compare correctly; this one was a really crazy gotcha in the Xcode 6 GM that required you to compare enum values using
!(x != y)(read the release notes folks!)
- You can use 64-bit integers as keys in a dictionary on 32-bit platforms
- If a class is exposed to Objective-C, you still can't declare a stored property of a generic type. Keep using the array workaround.
- The build system still gets confused if you don't have a Swift file in your project but include frameworks, app extensions, etc that do. Just add a dummy
.swiftfile to the main target and the problem goes away.
There are a few other things not covered here so I encourage you to check out the release notes.
Greetings San Francisco/Bay Area folks! We've got a place in Outer Sunset and the family is flying out to meet me soon. I'll have more details to share about what I'm working on soon, but I'll tag those posts to keep them separate. Those of you who only want the Swift posts can steer clear.
This blog represents my own personal opinion and is not endorsed by my employer.