Tuesday, July 7, 2015

What's New in XCode: WWDC 2014 (August)


Major Areas

  1. Swift
  2. Live Design
  3. Visual Debugging
  4. Performance Testing

 Swift Overview

  • A brand new language.  
  • Framework header files are available in Swift syntax.
  • Playgrounds allows executing your code more rapidly, as you are authoring it.
  • QuickHelp shows a short in-line description, at the time you are using auto-complete.
  • When using inferred types, such as "let x = ...", swift can tell you what the inferred type is that will be assigned, by using mouse over on the statement. 
  • Can have .h, .m and .swift files side by side, working together. 

Design Features Overview

  • XCode 6 now allows using storyboards to develop OS10 applications.
  • Using custom fonts will now show up in interface builder on the canvas. 
  • Sprite kit level editor lets us visually assemble scenes. 
  • New way to localize applications:  Export all localizable assets into XLIFF (XML Localization Interchange File Format), which is an industry standard format.  Then import the translated file back into XCode to merge in the localized content into the project.
  • @IBDesignable allows flagging your class for having certain elements show up in IB. 
  • @IBInspectable allows flagging certain variables to be configured and shown in IB. 

Debugging Overview

  • XCode 6 shows how the block got into the stack queue.  In the stack trace that looks like: "Enqueued from com.apple.uikit...." 
  • If you are developing an App Extension, XCode automatically attaches the debugger to your extension when you bring up the notification centre on the device. 
  • New debug instrumentation guages for finding problems in File and Network IO. 
  • View Debugger allows inspecting the view hierarchy to understand why things don't look in the expected fashion.

Performance Overview

  • Instruments has a new UI. 
  • XCode Server gets Trigger support that gives custom behavior to your CI bots.  (Run command line scripts After integration step occurs).  Can run "On Success", "On Test Failures" or "On Build Errors".  
  • Performance test support added to the XCTest framework.   Wrap your code in [self measureBlock:^{ //your code }];     XCode will tell you if the speed of your code has improved or regressed.  
  • "Profile" option from the context menu when right clicking on the test itself allows regenerating profiles for individual tests. 
  • New report that summarizes performance tests. 


Swift Demo (Daniel Dunbar)

  • Module names can now be specified for classes in Interface builder.  So you can use short class names, and avoid naming collisions by using different modules. 
  • Can now define our own modules in our own frameworks, and use them in both Swift and Objective-C.   For example you can put all model code into a "Core" type of module.
  • In Swift, you no longer need to manually import individual headers from a module.  Just import the module itself, and all the public classes will be accessible.   
  • You will get inline auto-complete quick help docs even when using your own classes. 
  • Typed Collection support allows specifying a cast to a type, for example:  " as Game[]" so now the compiler knows that we are dealing with an array of Game objects going forward.
  • iOS8 has a new "separatorEffect" visual property for TableViews.  (Set to a UIVisualEffect)
  • Objective-C Headers are dynamically translated to the Swift syntax on-the-fly, preserving original API comments.
  • Automatic Type inferrence automatically finds the right enumeration type.  So you can just type things like:  .Dark, and it will know which enum to use based on parameter type.  
  • A Header is automatically generated for you in the format:  "ModuleName-Swift.h".   You can import this header into any Objective-C file in order to gain access to all Swift classes within that Module. 
  • Option+Double Click opens Quick Help for any Symbol or Build Setting.  Quick help works across Swift and Objective-C. 

Interface Builder Demo (Jon Hess)

  • Playground shows you values of variables on the right.  Press + on any of the inspected variables in the right pane to bring up a persistent preview of any variable.  Results update immediately as you change the code. 
  • Desaturation effect example:  UIColor(white: 1.0, alpha: 1.0 - 0.3).set()  
  • Option + Click to open any resource in the assistant.  Such as the storyboard. 
  • @IBDesignable indicates that your object should be of specified type at Design type, not just at Run Time.  So in IB, your class will be executed by Interface builder, and look as you intended it to according to your code-behind. 
  • override func prepareForInterfaceBuilder() {  }   can be overridden to make sure that the view is set up to properly show up in IB.  Set up a default image here, or anything you need to do. 
  • @IBInspectable can be applied on member variables, which exposes them as fields in IB that can be set. 
  • In IB you can click on a View, then go "Debug Selected Views", and the related code to draw that View will be called, allowing you to debug into it without running your project from scratch.   
  • New Feature: Universal Storyboards allows to target to both the iPad and iPhone.  To enable:  click on your storyboard, and in the File inspector, enable:  "Use Size Classes". 
  • You can specify which constraints participate for which size classes.
  • You can specify what segues do based on size class.  (For example:  Popover on the iPad, and a Modal on the iPhone). 
  • Preview tool allows viewing how your app will look on multiple screen sizes at the same time.  To activate:  Open the "Enhanced Preview Editor", and select" Preview: Main_iPhone.storyboard, for example.  Then on the bottom press + to add additional device types to the same preview screen. 
  • Size classes can be selected from IB's bottom Bar, that defaults to "Any".  Choose "Regular" to work with the largest size class (iPad).  The bottom bar will turn blue, to remind you that you are editing the design for a specific size class. 
  • Any changes done in IB when selecting a specific size class will only be applied to that size class. 
  • New Aspect Ratio constraint allows to pin the relationship between width and height. 

Debugger Demo (Ken Orr)

  • You can now mouse-over a UIView in the code, and click the QuickLook Icon to see a rendering of that view, to make sure that you are in the right place in the code.  Also works for Mac apps for NSView.
  • - (id) debugQuickLookObject is a new method you can implement on any of your classes.  It will be called by XCode when you initiate QuickLook from the debugger.
  • New "Debug View Hierarchy" button on the bottom.  Shows view snapshots, frames and a visual representation of your views.   Allows inspecting object types and their properties at run time.  
  • When you click on a view in the "Debug View Hierarchy" view, you can also navigate the "Bread-Crumb" on top to see how the view is embedded, and who owns it.  Now you know which area in the code is responsible for drawing any given view you're seeing, without having to guess. 
  • Twist the view sideways in the View Debugger.  
  • The Left slider allows separating views in the hierarchy further.
  • The Right slider allows hiding view from the front to the back, exposing underlying views. 
  • "Show Constraints" button hides all other views, and only shows you the view you selected, and its' constraints. 

Performance Demo (Kate Stone)

  • extension is a new Swift feature (Similar to category), which allows adding methods to a class. 
  • Example:  New File --> Test Case Class --> PerfTests. 
    • By default will contain the following methods:  setUp(), tearDown(), testExample(), testPerformanceExample()
  • testPerformanceExample() contains measureBlock { ... } by default. 
  • Performance test runs a few times to find an average run timing, and consistency of run-to-run timing.  
  • Mouse over the "No baseline..." warning after running the test.  And fill in the Baseline values to establish a baseline for the test. 
  • Right click the test --> "Profile", to launch instruments to profile that specific test only. 
  • Instruments doesn't immediately record anymore.  You can first change the settings now, before you start recording. 
  • Click and drag in the memory chart to filter a range of allocations in the timeline. 
  • Stack trees view in instruments shows a statistical breakdown of allocations by object type. 
  • XCode server gives a dashboard report of tests over time, success/failure history, and device specific results. 

No comments:

Post a Comment

The Mobile Startup: Episode 5: Some thoughts about tech, and work.

Knowing that You're Bad! I think that if you have never thought of yourself as a bad engineer before, then you are probably a Bad e...