UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

How to upgrade your apps for iOS 11 and Swift 4

Tips for the new design, the drag and drop APIs, and the great new Swift features.

Paul Hudson       @twostraws

It’s only a few more days until Swift 4 and iOS 11 become the new standard for iOS developers, and as soon as the Xcode 9 gold master is sent out developers everywhere will be able to make final updates to their code and submit to the App Store ready for iOS 11’s release to the general public.

If you’ve yet to prepare your app for Swift 4 and iOS 11, here are my top tips…

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Hold off on the new design…

Don’t adopt the new iOS 11 design hastily. Yes it really is the new standard, and no it’s really not that hard to take on board, but it’s a smart idea to take a few more weeks to plan your design update and do so sensibly.

I realize it can be annoying to wait, but trust me: if you wait just a month you’ll see many other apps update to iOS 11, and start to get a sense of what looks good using the new guidelines. It’s much better to let other apps make mistakes than rush your own updates and end up having to back-pedal!

If you want to start experimenting now, I wrote an article outlining the new iOS 11 user interface changes – you should start there.

…but go straight for drag and drop

Implement support for drag and drop immediately, if it makes sense for your app.

iOS 11 introduces some incredible new features such as Core ML, ARKit, Core NFC, and more (see here for code examples), but those are completely new to the platform and most apps won’t need them.

However, one big new feature is support for system-wide drag and drop, and that’s one thing you should add immediately unless you want your app to stick out like a sore thumb. Worse, if you don’t add drag and drop support, your users will complain loudly until you do, so honestly it’s just worth it to get the work done now.

Do the minimum work to get Swift 4 compatibility…

Swift 4 is a relatively small change compared to the epic rewrite of Swift 3, and as a result migrating your code to Swift 4 should take less than a day even for large codebases. If you were already using Swift 3.1 you should use the Swift migration tool – it should be able to take you 80% of the way there, but there will always be some extra fixes you’ll need to make by hand.

That being said, actually upgrading your code to use all the new Swift 4 features – Codable, multi-line string literals, the improved dictionary functionality, etc – will take a lot longer, because these features involve rewriting your code to use the new syntax and functionality.

Ultimately, making the pitch to management that you want to spend two weeks rewriting your code so that it uses Swift 4 features is tricky: it costs money, produces an end result that looks identical to what you have today, and in fact may even have more bugs because so much code has changed.

My advice: just focus on getting your code to compile, and focus on the rest of Swift 4 later on. In the meantime, you should learn what's changed in Swift 4, and in particular brace yourself for a few "argument of #selector refers to instance method that is not exposed to Objective-C" errors.

…but prepare for more work

On September 12th Apple is holding its latest launch event, and all rumors are pointing to them dropping a number of new devices. In particular, it looks like we might see a pretty remarkable new iPhone with a significantly larger screen, and it’s all but guaranteed Apple will release new APIs to take advantage of this.

Now, as much as I advise people to hold off jumping into new designs quickly, new devices are a different case. If the new iPhone really does change the way we position things on the screen, then apps that don’t update look extremely dated immediately.

Worse, in my experience early device adopters are the ones most likely to complain – after all, they just spent north of $1000 on their new device, and your app is making it look bad. On the flip side, if you’re one of the first apps to make their phone look great, you can be sure they’ll show their friends.

So, if Apple really does drop some new screen APIs next week, I would strongly recommend you try to integrate them into your app quickly.

BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.

Get it on Hacking with Swift+

Sponsor Hacking with Swift and reach the world's largest Swift community!

BUY OUR BOOKS
Buy Pro Swift Buy Pro SwiftUI Buy Swift Design Patterns Buy Testing Swift Buy Hacking with iOS Buy Swift Coding Challenges Buy Swift on Sundays Volume One Buy Server-Side Swift Buy Advanced iOS Volume One Buy Advanced iOS Volume Two Buy Advanced iOS Volume Three Buy Hacking with watchOS Buy Hacking with tvOS Buy Hacking with macOS Buy Dive Into SpriteKit Buy Swift in Sixty Seconds Buy Objective-C for Swift Developers Buy Beyond Code

Was this page useful? Let us know!

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.