Under The BridgeUnder The Bridge

Musings
Nine Releases Make An Xcode

All these new APIs are very well and all, but now let’s get to the really exciting stuff from WWDC:

What’s New in Xcode 9

  • All new editor. Fast, structure-based editor that lets you intelligently highlight and navigate your code. Includes great Markdown support.
  • Refactoring. Refactoring built right into the editing experience and works across Swift, Objective-C, Interface Builder, and many other file types.
  • Super-fast search. The Find navigator returns results instantly.
  • Debugging. Wirelessly debug iOS and tvOS devices over the network, new debuggers for Metal, and more features throughout Xcode.
  • Source Control. All new source control navigator and integrated support for GitHub accounts for quickly browsing repositories and pushing your repositories to the cloud.
  • Xcode Server built-in. Continuous integration bots can be run on any Mac with Xcode 9, no need to install macOS Server.
  • New Playground templates. Includes iOS templates designed to run well in both Xcode and Swift Playgrounds in iPad.
  • New Build System. An opt-in preview of Xcode’s new build system provides improved reliability and performance.

That is … a remarkable array of improvements. And those are just the highlights! Seriously, go Read The Whole Thing™. Most are runtime and debugging improvements, we’ll just pick out to highlight further here the changes in asset catalogs, since there’s some new resource stuff here you’ll want to be aware of to be iOS 11 savvy:

Asset Catalogs

  • Named colors support.
  • Added wide gamut app icons.
  • Added a larger iOS marketing to the App Icon set.
  • Added option to preserve image vector data for matching Dynamic Type scaling.
  • Added support for HEIF images.

The biggest one there is, as explained here,

Preserve Vector Data

There’s a new checkbox in the Asset Catalog Attributes Inspector called “Preserve Vector Data.” Checking this box will ensure that Xcode includes a copy of the PDF vector data in the compiled binary. At runtime, iOS can automatically upscale or downscale the vector data to output an image in your app whether you’re using the image in code or in a Storyboard scene. Remember: When using PDF vector data, set the “Scales” value to “Single Scale” in the Attribute Inspector to ensure the proper loading the PDF vector data to populate image.

This change also works in conjunction with the new Tab Bar icon HUD that Apple implemented as an accessibility feature in iOS 11. If you enable “Preserve Vector Data” this feature comes to your apps with no additional work. By enabling this feature, iOS 11 can also automatically scale images regardless of whether you’re increasing a UIImageView’s bounds, or using Size Classes to change an UIImageView size…

Screenshot samples at The Unexpected Joy of Vector Images in iOS 11.

And apparently Apple is bowing to popular pressure and making Xcode all but dependent on Github, see Xcode GitHub Integration and The Marriage of Github and Xcode 9. We’d mutter something curmudgeonly about why don’t you go full fanboi and replace the documentation with hotlinks to Stack Overflow too, but we’re worried they might take that idea seriously…

Community support we do find quite appealing though, is how enthusiastically the new stuff is being open sourced:

Apple open sources key file-level transformation Xcode components

This afternoon at WWDC we announced a new refactoring feature in Xcode 9 that supports Swift, C, Objective-C, and C++. We also announced we will be open sourcing the key parts of the engine that support file-level transformations, as well as the compiler pieces for the new index-while-building feature in Xcode…

And if that bit about “new build system” struck terror into your massively scripted heart, fear not, it appears to be pretty much a behind the scenes change all around:

New Xcode Build System and BuildSettingExtractor

The new system is written in Swift and promises to be a significant advance in a number of areas including performance and dependency management. The new system is built on top of the open source llbuild project and lays the foundation for integrating the Xcode build system with the Swift Package Manager

It appears that everything about defining build settings remains unchanged. Moving between the old and new build systems did not cause any build setting changes or recommended changes. The mechanisms for generating that giant bucket of key-value pairs known as build settings seem to be just the same as before.

This is great news. As developers, we don’t need to learn a new complex system for defining build settings. We get to enjoy the benefits of a new, faster, modern build system with our existing build settings left intact…

(And if you haven’t moved to .xcconfig files yet, or if you do them by hand, seriously do go check out BuildSettingExtractor. So handy, we even contributed to it — and that’s as high praise as it gets, around these parts!)

That’s enough for a TL;DR to get you salivating for the new stuff — but if you missed our link to New stuff from WWDC 2017 last time, go check it out now; more details on Xcode changes there … and everything else as well. Veritably encyclopedic, that reference!

OK, one last note that isn’t Xcode 9 specific but you’ll want to refer to it anyways: iOS Simulator Power Ups. Something for everyone there!

UPDATES:

Hands-on XCUITest Features with Xcode 9

Customizing the file header comment and other text macros in Xcode 9

This iOS Goes To 11

Been enough of a while since WWDC ’17 for people to sort out what they find interesting about iOS 11 and all now, so let’s take a look shall we?

The canonical references up at the mothership are

A good TL;DR while you bookmark this for later is What’s new in iOS 11 for developers

iOS 11 By Examples has, surprise, examples of using new iOS 11 APIs:

  • Core ML: Image classification demo using Core ML framework
  • Vision: Face detection, landmarks, and object tracking
  • ARKit: Augmented reality experiences in your app or game
  • Core NFC: Reading of NFC tag payloads.
  • IdentityLookup: SMS and MMS filtering using IdentityLookup framework
  • DeviceCheck: Identifying devices that have used a promo, flagging fraudsters
  • Blogs/Newsletter: Other places that mentioned this list — probably mention more good stuff too!

Personally we’d already been planning to try out iPad-only travel soon, and iOS 11 + new iPad Pro looks like MASSIVE WIN on both fronts — seriously, did anybody at all predict the super duper ProMotion screen? — and the mutitasking stuff is a good bit better than we’d expected, and easy to use, see:

CoreNFC is one of those what took you so long things, but hey better late than never: CoreNFC tutorial

Now that Metal is even more metal to support 120 fps displays and all, they’re Introducing Metal 2

If you do anything with file names in iOS or macOS, make sure you read APFS Native Normalization

One thing worthy of noting as removing what we’d found the major annoyance with UIStackView and likely you too: Stack View Custom Spacing

Also top and layout guides are simplified to Safe Area Layout Guide

Some more little bites, to coin a phrase, at #309: UIFontMetrics and #310: Screen Edges in iOS 11 and #311: Round Corner Improvements

Now, to step back from the API level, some people are very excited about this Business Chat thing:

… I believe that Apple Pay Cash, and the ability to send low transaction amounts with no cost to the sender or the receiver (the business) will be one of the most transformative elements to the impact of Business Chat. This can bring rise to a number of new businesses and applications that may be similar to the “gig economy” of Fivver and other systems…

Business Chat can not only spell the end of the POS system and payment systems as we know it in retail sales, it may also spell the end of the shopping carts and payment systems in online sales. Some may argue this is bombastic…

Yes, maybe a touch. Doesn’t mean it’s wrong though; read the whole thing, and the Business Chat info at the mothership, and see what you think —or read this one that figures it’s not just shopping carts in the crosshairs: Apple Bank here we come

Last one we’ll call out here — some good thoughts on the new evolutions of the interface design language: Think Bigger: Design Changes in iOS 11

Need more? Check out your veritably canonical reference to everything new over at New stuff from WWDC 2017!

UPDATES:

Changes to location tracking in iOS 11

iOS 11, Privacy and Single Sign On

ARKit And Kaboodle

The other obviously transformational technology introduced at WWDC this year was Apple’s sudden leap from

One thing is clear: Apple needs to get moving soon.

to, a mere 5 days later — how’s that for “soon?” —

If Apple gets this right, they will own the hardware market for years to come.

and what we’re sure must be by far the quickest ever adoption of an Apple-only technology outside the computer industry,

Ikea’s plans for ARKit revealed, virtual shopping tool will launch in fall with iOS 11

so let’s start collecting links on that shall we?

Introducing ARKit

With ARKit, iPhone and iPad can analyze the scene presented by the camera view and find horizontal planes in the room. ARKit can detect horizontal planes like tables and floors, and can track and place objects on smaller feature points as well. ARKit also makes use of the camera sensor to estimate the total amount of light available in a scene and applies the correct amount of lighting to virtual objects…

… yeah ok that’s pretty cool.

There’s already signup open for ARKit Weekly to keep abreast of news here, and the same obviously extra-keen folk have also started

Made With ARKit: Hand-picked curation of the coolest stuff made with #ARKit

That’s some pretty darn nifty videos there for, like two weeks at this!

To grab some source code examples and interesting commentary, check out

Apple ARKit by Example

  1. Getting setup, draw a cube in virtual reality
  2. Plane Detection and Visualization
  3. Adding geometry and physics fun
  4. Physically Based Rendering

ARShooter – An Example Shooter Created Using iOS 11’s ARKit

ViewAR does first tests with ARKit

3 Things To Know About Apple’s ARKit

Apple’s new augmented reality platform may be its next game-changer

Pretty cool huh? It’s like the future’s so bright we have to wear shades … except the whole point of Apple AR (so far…) is that we don’t!

UPDATES:

ARBrush: “Quick demo of 3d drawing in ARKit using metal + SceneKit.”

ARKit Tutorial in Swift 4 for Xcode 9 using SceneKit

Watch a Tesla Model 3 come to life

ARTetris: “Augmented Reality Tetris made with ARKit and SceneKit”

Getting Started with ARKit: Waypoints

Core MLagueña

Checked out the WW17 Roundup yet? OK then, let’s start digging into this new stuff a little deeper. And we’ll start with the one with the most buzz around the web,

Introducing Core ML

Machine learning opens up opportunities for creating new and engaging experiences. Core ML is a new framework which you can use to easily integrate machine learning models into your app. See how Xcode and Core ML can help you make your app more intelligent with just a few lines of code.

Vision Framework: Building on Core ML

Vision is a new, powerful, and easy-to-use framework that provides solutions to computer vision challenges through a consistent interface. Understand how to use the Vision API to detect faces, compute facial landmarks, track objects, and more. Learn how to take things even further by providing custom machine learning models for Vision tasks using CoreML.

By “more intelligent” what do we mean exactly here? Why, check out

iOS 11: Machine Learning for everyone

The API is pretty simple. The only things you can do are:

  1. loading a trained model
  2. making predictions
  3. profit!!!

This may sound limited but in practice loading a model and making predictions is usually all you’d want to do in your app anyway…

Yep, probably. Some people are very excited about that approach:

Apple Introduces Core ML

When was the last time you opened up a PDF file and edited the design of the document directly?

You don’t.

PDF is not about making a document. PDF is about being able to easily view a document.

With Core ML, Apple has managed to achieve an equivalent of PDF for machine learning. With their .mlmodel format, the company is not venturing into the business of training models (at least not yet). Instead, they have rolled out a meticulously crafted red carpet for models that are already trained. It’s a carpet that deploys across their entire lineup of hardware.

As a business strategy, it’s shrewd. As a technical achievement, it’s stunning. It moves complex machine learning technology within reach of the average developer…

Well, speaking as that Average Developer here, yep this sure sounds like a great way to dip a toe into $CURRENT_BUZZWORD without, y’know, having to actually work at it. Great stuff!

Here’s some more reactions worth reading:

Here’s some models to try it out with, or you can convert your own built with XGBoost, Caffe, LibSVM, scikit-learn, and Keras :

  • Places205-GoogLeNet CoreML (Detects the scene of an image from 205 categories such as an airport terminal, bedroom, forest, coast, and more.)
  • ResNet50 CoreML (Detects the dominant objects present in an image from a set of 1000 categories such as trees, animals, food, vehicles, people, and more.)
  • Inception v3 CoreML (Detects the dominant objects present in an image from a set of 1000 categories such as trees, animals, food, vehicles, people, and more.)
  • VGG16 CoreML (Detects the dominant objects present in an image from a set of 1000 categories such as trees, animals, food, vehicles, people, and more.)

And some samples and tutorials:

Also note NSLinguisticTagger that’s part of the new ML family here too.

For further updates we miss, check out awesome-core-ml and Machine Learning for iOS !

UPDATES:

YOLO: Core ML versus MPSNNGraph

Why Core ML will not work for your app (most likely)

Blog: Getting Started with Vision

MLCamera – Vision & Core ML with AVCaptureSession Inceptionv3 model

Can Core ML in iOS Really Do Hot Dog Detection Without Server-side Processing?

Bringing Machine Learning to your iOS Apps 🤖📲

Creating A Simple Game With CoreML In Swift 4

Custom classifiers in iOS11 using CoreML and Vision

Using Vision Framework for Text Detection in iOS 11

WWDC 2017 Roundup

That was a particularly good WWDC this year wasn’t it? Lots of possibly transformational technologies introduced it’s going to be very interesting indeed to see how they play out!

We’ll explore those in more depth later on, but for now let’s sort out some resource links and initial reactions.

First up, you want to go download The Unofficial WWDC app for macOS:

4a5b0d11384fd46acdbe8f552a5b85a7

Isn’t that pretty? Definitely your WWDC video viewing app of choice, we say!

Next, address this problem

687474703a2f2f63646e2e6d656d6567656e657261746f722e6e65742f696e7374616e6365732f343030782f32313932383230372e6a7067.jpeg

with the WWDC-Downloader script over at Github.

(And while that’s all downloading for your next transcontinental plane flight or whatever, have your heart warmed with

WWDC17 Scholarship winner Kenny Batista shared his experiences at Apple’s big week for developers !)

If you want to prioritize a bit, here’s a WWDC 2017 Viewing Guide that looks solid.

There’s enough interesting new technologies that they deserve roundup posts each as there’s going to be a lot of figuring out there to keep track of, so for now we’ll just link a couple overviews hitting the highest points:

The 2017 Apple Design Award Winners

WWDC 2017 Initial Impressions from the Wenderlich team

Another take from the Big Nerd Ranch crew at WWDC 2017: Helping You Get Things Done

Also check out their article New HEVC & HEIF Media Formats: What You Need to Know and Begun, The Codec War Has for background on the fur that’s no doubt going to be flying all over about that soon.

Oh, and we’ll put An In Depth Look At the New App Store and New rules following WWDC 2017 here too — there’s some interesting changes there you want to be aware of. Most notably to us, that finally The new iOS App Store lets devs choose whether or not to reset ratings when updating!! Woo-woo-woohoo!

And as always, over at mjtsai.com you can find a near-canonical list of WWDC 2017 Links for deeper diving!

UPDATES:

HEIF: A First Nail in JPEG’s Coffin?

MyLivePhoto

Way back in the day our first reaction to Live Photos was er, Apple reinvented the GIF, yay? But obvious though you’d think a simple conversion app would be, far as we’ve noticed no one got off their butts and actually did anything about it … until now!

Our magnificently esteemed (even if he is French) coworker JB Stevenard’s latest is called — just to make it totally clear —

MyLivePhoto – Convert Live Photo – GIF Frame Movie

and, y’know, you want those Live Photos as a movie or a GIF or a picked frame, this really does look like the easiest way there is to go about it. So we recommend you grab that while it’s free!

And just as a demonstration of how to use its power for EVIL … here’s your FULL SIZE LiveGIF of the morning rush hour traffic over in Ha Long Bay:

So yep, yep it works. Might want to apply a little more common sense than we did here to how you actually use its output, but if you want to have a 5 meg pageload … now it’s easy!

New Bestie: Microsoft?

Feels pretty strange writing this when you lived through the 80s and 90s, but Microsoft is kinda on a roll helping out Apple-based programmers recently, isn’t it?

First off, Visual Studio Code is definitely our favorite Electron app, and is rapidly taking over pretty much all our text editing needs not done in Xcode.

Then, we have Visual Studio for Mac! OK, what we really have is a rebranded Xamarin, yes. That’s still a massive leap forward in officially endorsing practical cross-platform options by anybody’s lights, and downright glorious if you’re a Mono/C# fan. Or a Unity game dude. Or a .NET Core server dude. Or someone who loves shopping at NuGet.org. Or, people who like working with Docker and/or Azure:

Visual Studio for Mac: now generally available

Since we released the first Visual Studio for Mac preview last November, we’ve been working hard on porting over the web editor tools from Visual Studio on Windows. Now with this release, you have full support to build out rich web-based applications using ASP.NET Core and front-end languages like HTML5, CSS3, and JavaScript.

And when your web app is perfectly polished and ready for release, you can directly publish to Azure using the new Publish to Azure wizard, without having to leave the IDE…

… today we also talked about some great new preview features, which we’ll make available in our alpha channel really soon. These are preview features that are not present on the stable release, but ready for you to try once released and give us feedback:

  • Docker support: supporting deploying and debugging of .NET Core and ASP.NET Core in Docker containers.
  • Azure Functions support: use this preview to develop, debug and deploy Azure Functions from your Mac.
  • Target IoT devices: target IoT devices like Android Things with your C# code and Xamarin.

That’s … quite the toolkit to have officially supported by Microsoft on macOS!

But what’s got us really paying attention now isn’t actually the tools, interesting as those are. We’ve been feeling a little bit grumbly about Google grabbing up Crashlytics et al. and the ALL YOUR DATA BELONG TO GOOGLE licensing terms coming into force, so this looks very very interesting indeed:

More Platforms, More Choices, More Power: Visual Studio Mobile Center at Build

Last fall we introduced Visual Studio Mobile Center (Preview), a cloud service designed to help developers manage the lifecycle of their mobile apps and ship higher-quality apps faster than ever. Today we announced several exciting improvements that expand the features of the service and extend Mobile Center to new audiences and platforms…

A great CI/CD pipeline is critical to delivering software quickly and with confidence. The Mobile Center Build, Test, and Distribute services are designed to make this a part of every developer’s workflow. Our Crash reporting and Analytics services ensure that you can learn about each release’s quality and usage, but a common request we’ve heard from developers is the ability to send Push messages using Mobile Center Analytics data to help ensure that the right end-user is receiving timely notifications. This tightens the loop from check-in all the way through deep engagement with end-users.

With our new Push service, Mobile Center developers can send targeted messages to specific sets of users at exactly the right time. Customers can create segments based on over a dozen different properties, including carrier, language, device model, screen size, and time zone, with many more to come…

Several Preview customers told us they loved our Test service, but they wanted to write their tests in a more familiar, platform-specific framework. We listened, and we now support XCUITest and Espresso, the native test frameworks for iOS and Android. Now developers can write their automated UI tests in their preferred languages and port existing tests to Mobile Center Test…

Mobile Center has offered a powerful beta tester distribution service since our first preview, with successful builds automatically sent to testers with ease. Developers have told us they’d love this same mechanism to let them deploy the applications to app stores and company portals.

With our new enhancements to the Distribute service, once a developer is confident about their apps quality, they can promote the latest build directly to an app store or company portal. Today you can do this with Google Play, and very soon we’ll be adding connectors for Intune, the App Store, and the Windows Store…

Mobile Center is the next generation of HockeyApp. Starting today, we’re launching the first step in our transition plan for HockeyApp users: use existing apps from HockeyApp inside Mobile Center, analyze crash reports and analytics, and connect to the Build, Test, and Push services…

New mobile platforms, testing frameworks, push services, and repo support are just the beginning—we have a lot more coming soon. Deployments to consumer app stores and secure private portals will be coming in the next few months, as will increased support for UWP, parity with our HockeyApp and Test Cloud services, and entirely new cloud development services. Sign up now to get started!

Yup … we’re thinking that looks like a really attractive alternative to Google-dependent lifecycle management for our apps. We’ve signed up, we’ll use it for our next cross-platform app, and see how that goes!

UPDATES:

Mobile Center plugin for fastlane

New Bestie: Microsoft?

Feels pretty strange writing this when you lived through the 80s and 90s, but Microsoft is kinda on a roll helping out Apple-based programmers recently, isn’t it?

First off, Visual Studio Code is definitely our favorite Electron app, and is rapidly taking over pretty much all our text editing needs not done in Xcode.

Then, we have Visual Studio for Mac! OK, what we really have is a rebranded Xamarin, yes. That’s still a massive leap forward in officially endorsing practical cross-platform options by anybody’s lights, and downright glorious if you’re a Mono/C# fan. Or a Unity game dude. Or a .NET Core server dude. Or someone who loves shopping at NuGet.org. Or, people who like working with Docker and/or Azure:

Visual Studio for Mac: now generally available

Since we released the first Visual Studio for Mac preview last November, we’ve been working hard on porting over the web editor tools from Visual Studio on Windows. Now with this release, you have full support to build out rich web-based applications using ASP.NET Core and front-end languages like HTML5, CSS3, and JavaScript.

And when your web app is perfectly polished and ready for release, you can directly publish to Azure using the new Publish to Azure wizard, without having to leave the IDE…

… today we also talked about some great new preview features, which we’ll make available in our alpha channel really soon. These are preview features that are not present on the stable release, but ready for you to try once released and give us feedback:

  • Docker support: supporting deploying and debugging of .NET Core and ASP.NET Core in Docker containers.
  • Azure Functions support: use this preview to develop, debug and deploy Azure Functions from your Mac.
  • Target IoT devices: target IoT devices like Android Things with your C# code and Xamarin.

That’s … quite the toolkit to have officially supported by Microsoft on macOS!

But what’s got us really paying attention now isn’t actually the tools, interesting as those are. We’ve been feeling a little bit grumbly about Google grabbing up Crashlytics et al. and the ALL YOUR DATA BELONG TO GOOGLE licensing terms coming into force, so this looks very very interesting indeed:

More Platforms, More Choices, More Power: Visual Studio Mobile Center at Build

Last fall we introduced Visual Studio Mobile Center (Preview), a cloud service designed to help developers manage the lifecycle of their mobile apps and ship higher-quality apps faster than ever. Today we announced several exciting improvements that expand the features of the service and extend Mobile Center to new audiences and platforms…

A great CI/CD pipeline is critical to delivering software quickly and with confidence. The Mobile Center Build, Test, and Distribute services are designed to make this a part of every developer’s workflow. Our Crash reporting and Analytics services ensure that you can learn about each release’s quality and usage, but a common request we’ve heard from developers is the ability to send Push messages using Mobile Center Analytics data to help ensure that the right end-user is receiving timely notifications. This tightens the loop from check-in all the way through deep engagement with end-users.

With our new Push service, Mobile Center developers can send targeted messages to specific sets of users at exactly the right time. Customers can create segments based on over a dozen different properties, including carrier, language, device model, screen size, and time zone, with many more to come…

Several Preview customers told us they loved our Test service, but they wanted to write their tests in a more familiar, platform-specific framework. We listened, and we now support XCUITest and Espresso, the native test frameworks for iOS and Android. Now developers can write their automated UI tests in their preferred languages and port existing tests to Mobile Center Test…

Mobile Center has offered a powerful beta tester distribution service since our first preview, with successful builds automatically sent to testers with ease. Developers have told us they’d love this same mechanism to let them deploy the applications to app stores and company portals.

With our new enhancements to the Distribute service, once a developer is confident about their apps quality, they can promote the latest build directly to an app store or company portal. Today you can do this with Google Play, and very soon we’ll be adding connectors for Intune, the App Store, and the Windows Store…

Mobile Center is the next generation of HockeyApp. Starting today, we’re launching the first step in our transition plan for HockeyApp users: use existing apps from HockeyApp inside Mobile Center, analyze crash reports and analytics, and connect to the Build, Test, and Push services…

New mobile platforms, testing frameworks, push services, and repo support are just the beginning—we have a lot more coming soon. Deployments to consumer app stores and secure private portals will be coming in the next few months, as will increased support for UWP, parity with our HockeyApp and Test Cloud services, and entirely new cloud development services. Sign up now to get started!

Yup … we’re thinking that looks like a really attractive alternative to Google-dependent lifecycle management for our apps. We’ve signed up, we’ll use it for our next cross-platform app, and see how that goes!

May The 4th Be Swift You

Got your Swift 3 rewrites all done? Good, good, because now it’s time for…

What’s new in Swift 4.0

Swift 4.0 is a major new release for everyone’s favorite app development language, and introduces a variety of features that let us write simpler, safer code. You’ll be pleased to know it’s nothing as dramatic as the epic changes introduced with Swift 3.0, and indeed most changes are fully backwards-compatible with your existing Swift code. So, while you might need to make a handful of changes it shouldn’t take long.

WARNING: Swift 4 is still under active development. I’ve selected some of the most interesting and useful new features for discussion below, all of which are implemented and available to try now. Please keep in mind that more features are likely ship in the months before final release.

  • Swifty encoding and decoding…
  • Multi-line string literals…
  • Improved keypaths for key-value coding…
  • Improved dictionary functionality…
  • Strings are collections again!…
  • One-sided ranges…
  • There’s more still to come…

The first release of Xcode that ships with Swift 4 is likely to arrive in June, presumably along with iOS 11, tvOS 11, watchOS 4, and macOS Somewhere Else In California. What we’ve seen so far is already promising, particularly because it’s clear the team is working hard to make Swift 4 as additive as possible. Primarily adding new features rather than breaking or modifying existing ones should make it easier to upgrade to, and hopefully signals the start of a new stability for the language…

One feature that was postponed was ABI compatibility, which would allow developers to distribute compiled libraries – one of the few key missing features that remain in Swift today. Hopefully we’ll get it before Swift 5…

So if you want to get a jump on this year’s Grand Transition, go check that out.

And if you’re really eager:

Playground: Whatʼs new in Swift 4

I made an Xcode playground that lets you try out many of the new features coming in Swift 4. You can download it on GitHub.

The cool thing is that you can run the playground right now in Xcode 8.3; you donʼt have to wait for the first official Swift 4.0 beta, which will probably come as part of Xcode 9 at WWDC. All you need to do is install the latest Swift snapshot from swift.org (donʼt worry, itʼs easy)…

Hands-on code examples to help you learn what’s new in Swift 4: new encoding and decoding, smarter keypaths, multi-line strings, and more!

Yeah, personally I think we’ll manage to contain ourselves for that 17 more days, thanks. Handy playground to have around then though!

UPDATES:

Building Swift Projects In Source Compatibility Mode

Breaking changes in Swift 4

What’s New in Swift 4?

Encoding and Decoding in Swift 4

Migrating to Swift 4

What’s New in Swift (WWDC 2017.402)

WWDC videos on Swift:

Exploring the new String API in Swift 4

The surprising awesomeness of Grouped Dictionaries

The startling uniquing of Swift 4 dictionaries

Functional Lenses: an exploration in Swift

Kuery: “A type-safe Core Data query API using Swift 4’s Smart KeyPaths”

Parsing JSON in Swift 4; JSON Parsing in Swift 4; Ultimate Guide to JSON Parsing With Swift 4; JSON with Encoder and Encodable

Friday Q&A 2017-07-14: Swift.Codable, Swift 4 Decodable: Beyond The Basics; Swift 4’s Codable: One last battle for Serialization

What’s New in Swift 4 by Example

Key Value Observation in iOS 11

Swift Witness For Sourcery

Yep, think we’ve outdone ourselves with the obscure title references this time. If you knew it was from Malachi 3:5, our congratulations!

What we’re talking about today is what you might have noticed when it was named Insanity, but these days is called Sourcery:

What is Sourcery?

Sourcery scans your source code, applies your personal templates and generates Swift code for you, allowing you to use meta-programming techniques to save time and decrease potential mistakes.

Using it offers many benefits:

  • Write less repetitive code and make it easy to adhere to DRY principle.
  • It allows you to create better code, one that would be hard to maintain without it, e.g. performing automatic property level difference in tests
  • Limits the risk of introducing human error when refactoring.
  • Sourcery doesn’t use runtime tricks, in fact, it allows you to leverage compiler, even more, creating more safety.
  • Immediate feedback: Sourcery features built-in daemon support, enabling you to write your templates in real-time side-by-side with generated code.

Sourcery is so meta that it is used to code-generate its boilerplate code

We’re pretty leery of tools like this in general as they end up being yet another cesspool of technical debt, but that this one is based on SourceKitten is interesting enough to at least pay some attention to it. And it’s catching a bit of buzz:

How to Automate Swift Boilerplate Code with Sourcery

Switching between our Android projects written in Java (or more recently, Kotlin) and iOS projects in Swift makes me sorely miss annotation processing. Annotations in Java can be used to generate common code and things that Swift developers would have to hand write. Hand written code has to be bug free and consistently updated and maintained. Things like implementing equals and parsing JSON typically require boilerplate code, unique enough that you cannot abstract it away.

Although Swift does not have annotation processing, we can get pretty close with Sourcery. Let’s take a look at how it all works in this quick Sourcery tutorial…

AutoEquatable and AutoHashable by Sourcery

I’m really interested in Sourcery, so I installed it in my one of repositories. In my case, I generated AutoEquatable and AutoHashable at first because I felt these implementations contain really a lot of boilerplate codes…

If I add a new property or a new API, it prevents a human error! Though it looks trivial, Sourcery uses a safe Hashable as I mentioned in Safe Hashable in Swift. Isn’t it cool?

The Magic of Sourcery

Sourcery is a code generation tool for Swift. It is particularly well suited for auto-generating code that is very repetitious; code most developers refer to as “boilerplate”. Some examples that come to mind:

  • Equatable implementations
  • Hashable implementations
  • struct initializers
  • Lens implementations …

Sourcery — Meta-programing in Swift

Think of the potential : you can basically generate all the boilerplates of your architecture be it CLEAN or VIPER, you can generate all the protocol implementation or even the Realm data object, or even a view based on the variables that are being declared ( Sourcery do support inline code generate ). A declarative view ! The sky is the limit !

Meta Programming Swift with Sourcery

#292: Metaprogramming with Sourcery 🔮

#294: Annotations with Sourcery 🔮

#295: Building an API client with Sourcery Key/Value Annotations 🔮

If you’re looking for a good project to try this out with, a decent set of VIPER templates would be eagerly welcomed. Let us know if you come up with something!