By Peng Xie
iOS8: More power, More possibilities
Xcode and Swift: Good has just become better
Like many iOS developers, Xcode is one of my most often used applications on my Mac. I don’t always like Xcode. But I have to say, as the go-to iOS development tool, Apple is making Xcode a better tool each time a new version is released. Xcode 6 is no exception. Before we dive into Xcode, let’s talk about the Swift language first. I think Swift is the biggest surprise from Apple since the introduction of Macbook Air. There was absolutely no prediction that Apple was going to introduce a brand new language in this year’s WWDC keynote. Swift has really shocked the iOS developer community (in a good way, mostly) and you can tell that by looking at the expressions on the faces of developers attended the keynote. Given several advantages over Objective-C and ease to learn, Swift has become an instant hit among iOS developers and even potential developers who are trying to find a new language to learn. As the software quality company TIOBE pointed out, by the time they post the programming language popularity rank for July, Swift will probably be in the top 20. Swift is designed to be modern, safe and powerful. The modern character of Swift comes from the new features such as closures, tuples and generics. The syntax is easier to read and maintain than Objective-C and features like generics in Swift will also enables developers to do things they could never be able to do with Objective-C. Safety in Swift is ensured by eliminating classes of unsafe code and always initializing variables before use. Swift is also designed with the idea of being a powerful language in mind. It uses the high-performance LLVM compiler just like Objective-C and will be transformed into optimized native code to get the most out of Macs and iOS devices. With all that being said, Apple didn’t just released Swift as a single new language. All of Cocoa and Cocoa Touch as well as other libraries in iOS and OSX SDKs are updated to support Swift. And of course so it is with the latest Xcode 6.
Xcode 6 comes with many new features and some interface revamping. One of them is the Playground. Playground offers great ways to learn Swift, try new codes and develop custom views. The code is executed automatically and result appears immediately. Developers can see visualized results, imported resources, and created views in assistant editor. Several other features such as timeline slider are also available in the Playground to offer more functionalities.
Playgrounds are more just for trying out new stuff. When it comes for developing the interface, Apple now offers live rendering in the Interface Builder. Developers don’t have to build and run then switch between Xcode and simulators (or devices) to see the result of a custom view. In Xcode 6, the changes are automatically applied into your custom views in the Interface Builder. And for debugging the views, Apple has introduced the View Debugging feature which will turn the UI into a 3D rendering of each layer in the stack of views. Developing and debugging custom views has never been easier before. Speaking of Interface Builder, in addition to the newly introduced OSX Storyboard, Interface Builder now works with Size Classes. Instead of specifying Storyboards for different screen sizes and devices, developers now can use one Storyboard with Size Classes and Auto Layout for all screen sizes. And there is also the Preview mode to quickly check the interface without having to run the app. Last but definitely not the least, I want to talk a little bit about debugging. LLDB debugger became the foundation for debugging in Xcode 5. In Xcode 6, it has just become better with Swift REPL. Swift REPL, or Read-Eval-Print-Loop is an interactive version of Swift lives in the debugging console in Xcode or Terminal. Developers can use LLDB just as before but now it will also give debug information for Swift codes. It is also possible to validate existing code or even trying new codes right in LLDB with Swift REPL.
iOS8 and Xcode 6 has really opened more possibilities for both developers and Apple itself. iOS8 has laid the foundations for Apple to make more interesting new products such as iWatch and potentially some automated home control devices. Xcode’s new Storyboard with Size Classes also make it easier to develop apps for existing iPhones, iPads or even for the future iOS devices with larger screens. I believe when Apple releases their next generation devices and lifts the NDA on iOS8, the excellent iOS developer community will surprise the users with some pretty interesting apps we have never seen before. 2014 is going to be a good year for all iOS and OSX developers.