<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Oliver Jones on Medium]]></title>
        <description><![CDATA[Stories by Oliver Jones on Medium]]></description>
        <link>https://medium.com/@orj.codes?source=rss-189e9f2d7dfc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*PnqeifCYFF9ppueZ.</url>
            <title>Stories by Oliver Jones on Medium</title>
            <link>https://medium.com/@orj.codes?source=rss-189e9f2d7dfc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 16:35:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@orj.codes/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Getting better NSErrors from Swift 2’s ErrorType]]></title>
            <link>https://medium.com/@orj.codes/getting-better-nserrors-from-swift-2s-errortype-e9b7ac5ddd92?source=rss-189e9f2d7dfc------2</link>
            <guid isPermaLink="false">https://medium.com/p/e9b7ac5ddd92</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[error-handling]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[macos]]></category>
            <dc:creator><![CDATA[Oliver Jones]]></dc:creator>
            <pubDate>Fri, 12 Aug 2016 00:28:26 GMT</pubDate>
            <atom:updated>2016-08-15T00:04:08.381Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-sa/4.0/</cc:license>
            <content:encoded><![CDATA[<h3>Getting better NSErrors from Swift 2&#39;s ErrorType</h3><p>Cocoa has included <em>NSError</em> since version 10.2.7. It is the standard way of expressing and returning errors in Cocoa applications.</p><p><em>NSError</em> is not just an object to be consumed by simple error handling code. It has many properties and associated APIs, particularly on macOS, that make it eminently suitable for presenting directly to users.</p><p>Since the introduction of Swift 2 it has been possible to <a href="https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/ErrorHandling.html"><em>throw</em> Swift <em>ErrorType</em></a> instances and have them bridge automatically to <em>NSError.</em> Unfortunately this bridging behaviour is rather limited. <em>ErrorType</em> instances bridged to Objective-C APIs are very bare bone. They lack localised descriptions, failure reasons, recovery suggestions, help anchors and the like.</p><p>This might not seem so bad if you only develop mobile applications. Most iOS applications do not use features like <a href="https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ErrorHandlingCocoa/ErrorRespondRecover/ErrorRespondRecover.html">error recovery</a> or help anchors<em>.</em></p><p>If you develop macOS apps, <a href="http://revealapp.com/">like we do</a>, it is more of a problem. macOS has built in support for presenting rich error alerts using <em>-presentError:</em> on <em>NSResponder </em>or<em> NSAlert’s initWithError:</em>. If the <em>NSError</em> instance presented has a fully populated <em>userInfo</em> dictionary the user experience is greatly improved.</p><p>For example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lRG7SRY_g0sgrE4XMEXqsg.png" /><figcaption>An NSAlert presented using a rich NSError instance.</figcaption></figure><p>As opposed to:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ilL3L7JHp2QGDIOP6BYinQ.png" /><figcaption>An NSAlert presented with just an instance of ErrorType</figcaption></figure><p>Although iOS does not come equiped out of the box to present <em>NSErrors</em> to users the way macOS does, you can easily create a similar system for <em>NSError</em> presentation in your own apps using <em>UIAlertController, </em>or some other custom transient or inline alert. We’ve done exactly this in iOS apps we’ve developed for clients.</p><h4>The future is bright</h4><p>Swift Evolution proposal <a href="https://github.com/apple/swift-evolution/blob/master/proposals/0112-nserror-bridging.md">SE-0112</a> describes how future versions of Swift will improve the bridging of <em>Error</em> (the new name for <em>ErrorType</em>) to <em>NSError</em>. This proposal addresses all of the limitations of the current bridging behaviour.</p><h4>But for now, we have to fend for ourselves</h4><p>However, in the meantime, we’re stuck with Swift 2 — initial beta releases of Xcode 8 and Swift 3 didn’t include an implementation of <a href="https://github.com/apple/swift-evolution/blob/master/proposals/0112-nserror-bridging.md">SE-0112</a> but recently it has been implemented (i.e., Xcode 8 beta 5 includes the new Error protocol).</p><p>Below I present a simple mechanism for extending <em>ErrorType</em> to bring richer <em>NSError</em> behaviour to your iOS and macOS Swift 2 applications.</p><h4>NSErrorUserInfoValueProviding</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eea22f3b7c4e26a186199fd124aa5363/href">https://medium.com/media/eea22f3b7c4e26a186199fd124aa5363/href</a></iframe><p>This mechanism is not as sophisticated as the one proposed in <a href="https://github.com/apple/swift-evolution/blob/master/proposals/0112-nserror-bridging.md">SE-0112</a> but it does address some of the deficiencies in the existing Swift 2 <em>ErrorType</em> bridging behaviour. The <em>NSErrorUserInfoValueProviding </em>protocol above gives you an easy way of extending your <em>ErrorTypes</em> to include a localized description<em>, </em>failure reason or recovery suggestion.</p><h4>Note</h4><p>The code presented utilises APIs introduced in iOS 9 and macOS 10.11 — it will not work on earlier versions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qtwi6-ZnEe2_i-bdd1ImOA.png" /></figure><p><em>Based in Melbourne, Australia, </em><a href="http://ittybittyapps.com/"><strong><em>Itty Bitty Apps</em></strong></a><em> builds great software on mobile and Mac for clients big and small. It also makes </em><a href="https://revealapp.com/"><strong><em>Reveal</em></strong></a><strong><em> </em></strong><em>— Amazingly powerful runtime view debugging for iOS developers.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e9b7ac5ddd92" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When is the right time to adopt Swift 3?]]></title>
            <link>https://medium.com/itty-bitty-apps/when-is-the-right-time-to-adopt-swift-3-73604a348047?source=rss-189e9f2d7dfc------2</link>
            <guid isPermaLink="false">https://medium.com/p/73604a348047</guid>
            <category><![CDATA[cocoa]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[opinion]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Oliver Jones]]></dc:creator>
            <pubDate>Sun, 26 Jun 2016 06:07:35 GMT</pubDate>
            <atom:updated>2016-07-04T04:25:26.840Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aKS-gxGhJzLlxyWpc6NMgw.png" /></figure><p>It has been two years since Apple introduced Swift.</p><p>In the first 12 months I was quite hesitant to recommend Swift as an implementation language. In fact I think my exact words were “hell no”. The tools were not stable and the language and libraries were quite immature during Swift’s freshman year.</p><p>However, in the last 12 months the language has been going from strength to strength. Apple open sourced Swift and opened up the evolution of the language to the broader community through <a href="http://swift.org/">Swift.org</a>.</p><p>This has encouraged a wealth of community contributions to Swift through the <a href="https://swift.org/contributing/#participating-in-the-swift-evolution-process">Swift Evolution Process</a> and the upcoming release of Swift 3 bears fruit from these efforts. Swift 3 brings with it the most significant changes the language has seen in its short lifetime.</p><h3>Swift 3 and “The Great Renaming”</h3><p>Probably the most significant change coming with Swift 3 is “The Great Renaming”.</p><p>During this last year the Swift Evolution Process has produced a number of <a href="https://github.com/apple/swift-evolution">proposals</a> to clarify and standardise the naming scheme for the Swift Standard Library and how Swift imports Apple’s existing frameworks like Foundation, UIKit and Core Graphics. This has yielded the “<a href="https://developer.apple.com/videos/play/wwdc2016/403/">Swift API Design Guidelines”</a>.</p><p>This new naming standard means Swift 3 will be quite different from Swift 2 when working with these frameworks. With the move to Swift 3, nearly all existing Swift code will need to be migrated to the new naming standard and follow these guidelines.</p><p>Xcode 8 includes a migration tool to help with this transition. Tools are great but as is the case with most tools it is there to save you work, not remove all thought from the process. I’m of the opinion that all Swift application code will still need to be audited and reviewed by a human post migration. In addition, the migration tool can’t help you transition your existing application code to the new API guidelines. It only addresses how your code interacts with Apple’s frameworks and how that API has changed.</p><h3>Swift 3 and ABI stability</h3><p>One of the goals for Swift 3 was ABI stability. <a href="http://ericasadun.com/2016/05/16/winding-down-swift-3-0-abi-stability-deferred/">This didn’t happen</a>. What this means is that in order to upgrade a project to Swift 3 all the Swift dependencies of that project also need to be updated to Swift 3. It is not possible to link a Swift 3 application with Swift 2 libraries.</p><p>ABI stability will most likely come to Swift 3 sometime in the next 12 months and <a href="https://developer.apple.com/videos/play/wwdc2016/402/">at WWDC this year Chris Lattner</a> stated that maintaining source compatibility will be a strong constraint when considering changes to the language going forward. So hopefully there will be no need for a “Great Renaming 2” next year.</p><h3>When to Switch to Swift 3?</h3><p>Teams should start planning for this now. Depending on the scale of an existing Swift codebase this migration could have a significant impact on a project. All of a project’s dependencies will also need to have adopted Swift 3 before the main application can adopt Swift 3. Libraries adopting Swift 3 and migrating to the new API Guidelines will likely change their own APIs as a result. This will mean a lot of uses of library code in an application will need to be changed. Something the Xcode 8 migration tool can’t help with.</p><p>To ease with the adoption of Swift 3, developers should become familiar with the new <a href="https://swift.org/documentation/api-design-guidelines/">API Design Guidelines</a> and begin adopting them in new code as of today.</p><p>If you have an existing Objective-C codebase, and you’ve not yet started adopting Swift, then you may want to hold off adopting Swift until version 3 ships later in the year. This will put you in a better position than adopting Swift 2.x at this late stage and then having to go through the migration process.</p><p>Adopting Swift 3 right now, while it is in preview/beta, will be a painful process as very little 3rd party library code is ready yet. Although this will likely change rapidly during the Xcode 8 and iOS 10 beta period.</p><p>Fortunately, for developers who want to take a slow and steady approach to Swift 3 adoption, Apple have introduced features into Xcode 8 to allow developers to continue to use Swift 2 beyond the release of iOS 10. Xcode 8 supports both Swift 2.3 and 3. You can not mix them together in a single application but you can continue to use 2.3 until it is convenient for your project and team to make the Switch to 3.</p><h3>Is Swift the future of Cocoa development?</h3><p>Short answer: Yes.</p><p>I’ve always thought that a tipping point for Swift adoption would be when Apple themselves started introducing frameworks that were Swift only. While Apple has yet to go that far, they are <a href="https://developer.apple.com/videos/play/wwdc2016/207/">starting to introduce Swift only features to some of the foundation frameworks</a> upon which everything is built. Changes that make working with these frameworks feel much more native to the Swift language. These additions, and Apple’s introduction of <a href="https://developer.apple.com/swift/playgrounds/">Swift Playgrounds for iOS</a> as an educational aid speak to Apple’s commitment to push further toward a Swift only future.</p><p>It may be many years before Objective-C takes its final bows and exits the Cocoa development scene but on balance I think the advantages of Swift are quickly becoming apparent. If you’ve yet to jump on board the Swift bandwagon, the upcoming transition to Swift 3 might present the right opportunity to do so.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qtwi6-ZnEe2_i-bdd1ImOA.png" /></figure><p><em>Based in Melbourne, Australia, </em><a href="http://ittybittyapps.com/"><strong><em>Itty Bitty Apps</em></strong></a><em> builds great software on mobile and Mac for clients big and small. It also makes </em><a href="https://revealapp.com/"><strong><em>Reveal</em></strong></a><strong><em> </em></strong><em>— Amazingly powerful runtime view debugging for iOS developers.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=73604a348047" width="1" height="1" alt=""><hr><p><a href="https://medium.com/itty-bitty-apps/when-is-the-right-time-to-adopt-swift-3-73604a348047">When is the right time to adopt Swift 3?</a> was originally published in <a href="https://medium.com/itty-bitty-apps">Itty Bitty Apps</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>