Every year, some more so than others, Apple overwhelms us with a deluge of new features, APIs, platforms even, at WWDC.
It can be hard to contain your excitement for the new and shiny, as well as figuring out what actually matters for your day to day development.
In this post I’d like to take a slightly different approach and consider some of the underappreciated news from WWDC and how this impacts iOS and all of Apple’s platforms.
Foundation is the workhorse library underpinning most high-level development on Apple’s platforms. Hence, its release notes are required reading once the first developer seeds are released.
These typically feature both fundamental changes in behaviour throughout the SDK, such as the grand renaming by applying the Swift API Design Guidelines (SE-0023) and the introduction of Swift value types (SE-0069) where appropriate as well as more subtle adjustments and improvements.
Often incremental improvements to Objective-C are noted here too, such as string enumerations and class properties.
Occasionally, Foundation may end up sherlocking common third-party libraries like with the introduction of the ISO 8601 date formatter or date range formatters, while also adding new functionality such as support for measurements and units as well as delivering general performance improvements in key infrastructure like NSUserDefaults, KVO/KVC and friends.
More Release Notes
Platform-specific release notes such as for iOS include details that are typically more specific to certain use cases, but can be helpful to point out pitfalls when building with a new SDK and showstoppers which may well be a good reason not to install beta releases on your primary devices.
For example, once linked with the iOS 10 SDK, attempting to call
[someObject valueForKey:nil]; will result in a crash, as opposed to the previous undefined behaviour (which includes crashing of course).
This has finally come to an end, as documentation for corresponding symbols has been unified in a single API reference across all platforms, drastically streamlining browsing documentation.
However the old documentation library interface has not been entirely abandoned yet. You will still find long-form guides, sample code, references etc. here.
Unified Logging and Activity Tracing (Session 721)
iOS 10 and macOS Sierra bring with them an entirely overhauled unified logging subsystem.
While NSLog and other existing APIs will continue to work, these are in fact patched through to the new
os_log now supports multiple additional views on logs, based on subsystem, category and severity. Log levels are configurable when viewing logs, and low priority logs are only kept in memory, saving disk space for log histories. Even your console log output benefits from this, as by default the log category is now included in messages there.
The entirely rewritten log Console (Applications ▸ Utilities) reflects these changes and the improvement filtering options they entail.
os_log integrates with improved activity tracing, allowing logging to be tied to activities, which can in fact be nested and visualized using the new Console utility. This can help make flows and their related logging clearer. For example, a web framework may have nested activities for the various stages of request processing.
Unfortunately, as of Beta 3,
os_log is not entirely complete yet. While it has powerful configuration options on macOS, the format for configuration profiles to configure behaviour on iOS has not been released, and the logging methods are inaccessible from Swift for the time being.
Instrumentation: App Startup Time (Session 406)
While improved logging can bring better insights of a process’ runtime performance, what happens before
main() is called is often more of a mystery, but is often an issue when facing long launch times or more seriously, operating system level bugs which are hard to track down.
This session helps provide an overview of how binaries — be they executables, dylibs etc.—are structured and loaded as well as providing details of how your choices can impact the amount of time needed for this. Amongst other aspects, the
DYLD_PRINT_STATISTICS environment variable is demonstrated as a means to gain insights prior to
main() being called.
Instruments is a crucial tool for tracing application behaviour at runtime. Two sessions focused on how to use instruments more effectively.
At a lower level, System Trace, can be useful to squeeze out micro-second level optimisations, particularly for real-time tasks or graphics rendering.
The time profiler is more broadly useful to find hotspots worth investigating or tracking down what is causing unexpectedly high resource usage in an app. It has gained some new tricks this release, so watching the session covering it is certainly worthwhile.
What’s worth knowing?
This piece should provide an example of the less prominently advertised parts of WWDC and Apple’s software releases.
Knowing the Foundations we stand on, their release notes, where to find documentation as well as effective logging and instrumentation practices provide the bedrock for development work.