Skip to content

February 9, 2015

Swift 1.2 features an improved compiler and Objective-C interactions

by John_A

Apple’s youngest programming language, Swift, received a fairly substantial update with today’s first beta of Xcode 6.3, at least in beta form. The Swift 1.2 beta features an improved compiler that’s both more stable and more speedy, as well as new Objective-C (the programming language that pre-Swift iOS apps were built on) interactions for building more capable hybrid apps.

Here’s what’s new in the compiler:

  • Incremental builds — Source files that haven’t changed will no longer be re-compiled by default, which will significantly improve build times for most common cases. Larger structural changes to your code may still require multiple files to be rebuilt.
  • Faster executables — Debug builds produce binaries that run considerably faster, and new optimizations deliver even better Release build performance.
  • Better compiler diagnostics — Clearer error and warning messages, along with new Fix-its, make it easier to write proper Swift 1.2 code.
  • Stability improvements — The most common compiler crashes have been fixed. You should also see fewer SourceKit warnings within the Xcode editor.

In addition to the enhanced and improved compiler, Swift 1.2 also features improvements to the language itself:

  • as! for failable casts — Casts that can fail at runtime are now expressed with the new as! operator to make their potential for runtime failure clear to readers and maintainers of your code.
  • Nullability may now be expressed in Objective-C headers — New Objective-C extensions in Clang allow you to express the nullability of pointers and blocks in your Objective-C API. You can provide Objective-C frameworks that work great with Swift code, and improve your Swift experience when mixing and matching with Objective-C code in your own project.
  • Swift enums can now be exported to Objective-C using the @objc attribute.
  • let constants are now more powerful and consistent — The new rule is that a let constant must be initialized before use (like a var), and that it may only be initialized, not reassigned or mutated after initialization.
  • More powerful optional unwrapping with if let — The if let construct can now unwrap multiple optionals at once, as well as include intervening boolean conditions. This lets you express conditional control flow without unnecessary nesting.
  • New native Set data structure — An unordered collection of unique elements that bridges with NSSet and provides value semantics like Array and Dictionary.

As this is a beta of Swift 1.2 these features are, naturally, subject to change in behavior and implementation, and might not work perfectly out of this preliminary gate. But if you’re in the developer beta program, definitely check it out and see what you can do with these new additions to the language.

Source: Apple

Read more from News

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Note: HTML is allowed. Your email address will never be published.

Subscribe to comments

%d bloggers like this: