Under The Bridge Under The Bridge

Category: Programming
Rx For Reacting To Combine-ations

Remember all the fuss about FRP back when Reactive Cocoa was all the new hotness? Kinda a good chuckle as 2020 approaches, isn’t it? Whilst its appeal turned out to be, as they say, selective, it and later FRP libraries such as RxSwift do have a following among those who don’t mind fighting the framework (have us tell you the story of the MQTT/Core Data/RAC stack we parachuted in to save the day for some time, if you want to see a visibly apoplectic troll, but hey, we managed to drag it across the liquidity event finish line, it’s all good) but general consensus is of the RxNot mindset that designing for maintainability is difficult enough already without seriously considering an architecture lacking any first party support and actively hostile to established platform paradigms…

… and then, all of a sudden! Here. We. Are. With. Combine:

Introducing Combine: Combine is a unified declarative framework for processing values over time. Learn how it can simplify asynchronous code like networking, key value observing, notifications and callbacks.

Combine in Practice: Expand your knowledge of Combine, Apple’s new unified, declarative framework for processing values over time. Learn about how to correctly handle errors, schedule work and integrate Combine into your app today.

Well, that’s certainly a great deal of previously passionate architectural debates rendered instantly obsolete, t‘isn’t it now? OK, Rx fans, take yourselves a victory lap for being all ahead of the game, grab yourself the RxSwift to Apple’s Combine Cheat Sheet and call it a day. The rest of us, well, time to get catching up now!

The first bookmark you need is this veritable epic of online documentation, by virtually unanimous agreement the most comprehensive and reliable source on this subject, not excluding Apple:

Using Combine by Joseph Heck

The book is available online at no cost. If you find the content useful, please consider supporting the effort with a purchase of the PDF or ePub version. The money collected for sales of this book will go to hiring editors (copyediting and technical editing), and if sufficient funds exist, hiring graphic design for diagrams. The content for this book, including sample code and tests, are sourced from the GitHub repository

However, if that’s a little intimidating to dive right into, here’s our picks for the best quick reads and views to get started:

SwiftUI & Combine: Better Together

Combine101 by a coauthor on the inevitable Wenderlich book

Swift Combine Framework Tutorial: Getting Started

Getting started with the Combine framework in Swift

A Crash Course in Combine

OK then, now that we’ve got some basic grounding, let’s take a look at some real example apps:

MovieSwiftUI: “SwiftUI & Combine app using MovieDB API. With a custom Flux (Redux) implementation.”

2048-swiftui: “2048 game using SwiftUI and Combine.”

CombineSlotMachine: “A basic slot machine game that demonstrates using the Combine framework in a UIKit app.”

And the next place to check out is the GitHub repos and Slack channel at

Combine CommunityCommunity projects & experimentations around Apple’s Combine framework

Note particularly awesome-combineCombineDataSources, and CombineCocoa.

And here’s a selection of the more interesting miscellaneous tips and tricks we’ve found:

Modern Networking in Swift 5 with URLSession, Combine and Codable

Hmmm, looks like CareKit uses Combine and CoreData as a local database…”

Error Handling in Swift Combine Framework

Error handling in Combine explained with code examples

Debugging with Swift Combine Framework

Combine debugging using operators in Swift

GRDBCombine: “A set of extensions for SQLite, GRDB.swift, and Combine”

Using Combine to Supplement Delegates With Publishers

CombineGRPC, a library that integrates Swift gRPC and Combine

Map vs FlatMap vs SwitchToLatest

Simple custom Combine operators + Building a custom `sample` operator

Creating a custom Combine Publisher to extend UIKit

Backpressure in Reactive Streams

Playing With Combine: Grid Layout in SwiftUI

Should be right up to speed making it through all that!

Savoring A Fifth Of Swift

So it’s been a year of veritably epistemic closure on the Swift front, hasn’t it? With ABI stability in Swift 5 Released! and module stability in Swift 5.1 Released! why, it’s a serious language finally! We kid, we kid. If anything, it’s become more whimsical, it seems, what with these modifiers and wrappers and the good lord only knows what springing up like weeds; our favorite so far on the whimsicality front is definitely this — 

@dynamicCallable Part 3: Mustacheable

After Shell commands as Swift functions and the Swift/ObjC Bridge, Part 3 in our quest to find a useful application for the Swift 5 Dynamic Callable feature: Mustache templates as a function (short: MaaF). This one may actually make some sense…

Although the competition is tough indeed. Let us take the ExpressibleByStringInterpolation feature, generally recognized as both beauty and super-powered as string interpolations go — but would it strike you that you can apply it to text stream decoding?

Regular Expression Decoder: A decoder that constructs objects from regular expression matches.

RegularExpressionDecoder provides a convenient solution to constructing Decodable objects from regular expression matches by automatically matching coding keys to capture group names. And it can do so safely, thanks to the new ExpressibleByStringInterpolation protocol in Swift 5…

And then of course there’s the new custom string delimiters

Say, for whatever reason, you were in desperate need of Bill the Cat ASCII art in your app. Maybe you were very drunk and had a bet. Maybe you were working with some kind of Unix awk client. I dunno. Let’s just start with the proposition that this was a real and meaningful challenge in your life.

… right, at that point we’re approaching the absurd, never mind the whimsical, and when you check out some of the new NSHipsters, well…

Identifiable: What constitutes the identity of an object?

Philosophers have contemplated such matters throughout the ages. Whether it’s to do with reconstructed seafaring vessels from antiquity or spacefaring vessels from science fiction, questions of Ontology reveal our perception and judgment to be much less certain than we’d like to believe…

… new we’re into the downright surreal. As well as circling back to our original assertion of epistemically closed Swiftness, to wrap that diversion up with a nice bow and call it a day.

Any-ways, as always if you want a quick reference of changes between any set of Swift versions check out

What’s new in Swift?

And for some more in-depth collections, check out

raywenderlich.com’s What’s New in Swift 5? and What’s New in Swift 5.1?

hackingwithswift.com’s What’s new in Swift 5.0 and What’s new in Swift 5.1

Swiftbysundell.com’s 5 small but significant improvements in Swift 5.1

The biggest explosion of creativity has definitely been around Property Wrappers: check out

Swift Property Wrappers “will have arguably the biggest impact on the «je ne sais quoi» of Swift in version 5.1 and beyond”

Property Wrappers in Swift 5.1 “or How Swift decided to become Java”

ValidatedPropertyKit: “Easily validate your Properties with Property Wrappers”

Burritos: “A collection of well tested Swift Property Wrappers.”

Property wrappers to remove boilerplate code in Swift

Better Codable Through Property Wrappers

Swift Dependency Injection via Property Wrapper

Stop force unwrapping IBOutlets with @Delayed

Atomic property wrapper in Swift

How can Property Wrappers and Function Builders be leveraged?

Speaking of those Function Builders, there’s some interesting projects out there looking at them for all DSLy things:

Create Your First Function Builder in 10 Minutes

NSAttributedStringBuilder: “Composing NSAttributedString with SwiftUI-style syntax”

Vaux: “A HTML DSL library for Swift”

marina: “Understanding SwiftUI by reimplementing it to render to HTML”

The Swift 5.1 features that power SwiftUI’s API

Here’a aome other articles with various tips, tricks, techniques, and reminders about applying various syntactic niceties that have accumulated over the last few Swifts:

Dynamic Member Lookup combined with key paths in Swift

Swift 5.1 introducing key paths suddenly makes dynamic member lookup support a lot more interesting. It allows us to easily access values from an instance while keeping our models structured and small…

The Law: Atomics are hard

Swift 5 turns on exclusivity checking by default. This has some interesting interactions with atomics, especially when running under the Thread Sanitizer (TSAN)…

Different flavors of type erasure in Swift

This week, let’s start by taking a look at what makes type erasure such an essential technique in Swift, and then move on to explore different “flavors” of implementing it — and how each flavor comes with its own set of pros and cons..

Phantom types in Swift

This week, let’s take a look at a technique that can let us leverage Swift’s type system to perform even more kinds of data validation at compile time — removing more potential sources of ambiguity, and helping us preserve type safety throughout our code base — by using phantom types…

Regular Expressions in Swift

You may be surprised to learn that you can — in fact — use regular expressions in a Swift one-liner: you just have to bypass NSRegularExpression entirely…

How to use Result in Swift

Result has four other methods that may prove useful: map(), flatMap(), mapError(), and flatMapError(). Each of these give you the ability to transform either the success or error somehow…

Let’s stop filtering for a second

We’ll cover for loops versus filtering, using removeAll(where:), contains(where:), allSatisfy(predicate:), reduce, first(where:), and Swift 5’s count(where:)…

Creating Thread-Safe Generic Values in Swift

Well, we’re still waiting for coroutines in Swift several years in. In the meantime, we have many concurrency mechanisms to choose from…

Ordered Collection Diffing + Swift 5.1 Collection Diffing

This change adds native support for diffing and patching functionality for various collection types. Many state management patterns can benefit from this improvement…

Making types expressible by string interpolation

We can now express our Path type using any kind of string literal — which makes it much more convenient to use, while still giving us all of the benefits of stronger typing.

Efficiently Mutating Nested Swift Data Structures

Yep, Array & Dictionary both support in-place mutations. For Dictionary, the recommended way is to use the defaulting subscript…

The power of subscripts in Swift

a new feature that’s being introduced as part of Swift 5.1 — static subscripts — which work much the same way as instance subscripts, only that they enable us to subscript directly against a type itself…

That’s about it for now — time to sit back and relax for a while is it?

On November 5, 2019 the swift-5.2-branch branch will be cut…

The innovation, it never stops!


How Swift Achieved Dynamic Linking Where Rust Couldn’t

The Complete Guide to Property Wrappers in Swift 5

Offline Networking Management

So we have this new app that synchronizes all its operations with the website backend; and what, what, we ask rhetorically, do you figure the immediate cacophony of demand is?

Why, yes. Yes, it’s “Make checking in work offline!” Of course it is.

Now, 1.0 does cache all the last retrieved data so we’ve made a start on offline operation…

The Many Offline Options for iOS Apps

How to Design Offline-first Approach in a Mobile App

… so in this context, “work offline” is going to be defined as “queue database transactions to be applied to the server once connectivity is established,” as opposed to the current strategy of “call the API and do nothing if it fails”. We’re going to break that into a series of steps:

1) Currently our database transactions are UI state driven, with local changes applied only after online success, with a modal dialog forcing the user to wait. This is expedient, but annoying, and fallible.

So what we’ll do is encapsulate all our transactions into undoable objects, apply them to the local database immediately, and queue them for retry or cancel, ie. undo, if the online synchronization fails. Since having a functioning Undo implementation is a fine idea in any case, and helps us abstract out this rearchitecting nicely. If like us you haven’t implemented Undo recently (like in Swift at all) here’s some good tips on that:

Adding Undo and Redo support to iOS

UndoManager Tutorial: How to Implement With Swift Value Types

2) We’re going to need some awareness of when connectivity is established, to trigger applying these transactions to the server. Alamofire our networking layer has a simple one, implemented like thousands of others on top of ancient code. However, it has its issues … and there is a better option these days (iOS 12+): NWPathMonitor

Network Framework in iOS: How to Monitor Network Status Changes with sample code

Detecting Internet Access on iOS 12+ … now supported in Connectivity along with Solving the Captive Portal Problem. And backwards compatible Reachability support. So that looks like an excellent choice for network awareness needs!

And as an aside here, if you want to prompt people who turn off your app’s mobile data to turn it back on, check out

Handle disabled mobile data setting on iOS

However, for this particular application we can see that being a popular setting seeing as it’s all about foreign travel and all, so we’re not going to fuss about it as only working on wifi would be very likely indeed to be the users’ preferred mode of operation.

Speaking of operations, that brings us to:

3) A serializable and resumable and retryable queue for managing these operations

Right now we have a pretty simple asynchronous Operation wrapper for simple serial queuing of background data refresh operations, not completely unlike the network Operations described here,

Building a Networking Layer with Operations

Download files sequentially using URLSession inside OperationQueue

and as mentioned in the first point we’ll be making their local transactions undoable; but we’re going to need something a little more high powered than a stock memory OperationQueue to handle these, won’t we? Well, there are a number of possibilities mentioned that have various levels of support for persistence and awareness mentioned over in that promises roundup we did long before Combine was on the horizon, but here is one of particular interest:

OfflineRequestManager: Pod for Offline Network Request Management

OfflineRequestManager is a Swift framework for ensuring that network requests are sent even if the device is offline or the app is terminated.

OfflineRequestManager works by enqueuing OfflineRequest objects wrapping the network request being performed and observering the current network reachability using Alamofire. If the app is already online, then it will be performed immediately…

…! If a network-related error is passed into the completion block, then the OfflineRequestManager will retain the request and try again later. Other errors will by default remove the request from the queue, but there are optional delegate methods to allow for adjustment and resubmission if needed.

Realistically, there will likely be some data associated with the request. You also may want to be sure that the request is sent up even if the app is quit or (heaven forbid!) crashes…

Well, that would be … pretty much our exact feature requirements, actually! Hasn’t been updated in a year from Swift 4.0, so we’ll reimplement it in Swift 5.1 and add NWPathMonitor savviness and all, but a modernization is quite a less imposing task than designing from scratch, yes?

… and as a stretch goal, we’ll see about it taking advantage of background tasks too. You check out that new framework?

Managing background tasks with the new Task Scheduler in iOS 13

How to use BackgroundTasks framework to keep your iOS app content up to date?

So definitely, a superlatively up to date network request manager would also take advantage of that for recurring tasks!

The Niantic Beyond Reality Developer Contest

Got a great AR game idea burning a hole in your head and all you need is the infrastructure behind Pokémon Go? Well, not only is that available…

Niantic’s Real World Platform combines a world-scale persistent state engine, multiplayer AR, high-speed networking, geolocation data, and much more to create unique experiences that promote a sense of imagination and adventure…

… there’s a competition on to get paid to do a prototype with it!

The Niantic Beyond Reality Developer Contest

We invite you to reach beyond reality and apply for the Niantic Beyond Reality Developer Contest. Explore and create an impactful geospatial AR play experience with the Niantic Real World Platform, and compete for your share of a prize pool of more than one million USD.

For more details on the contest, please check out our blog and please see the Niantic Beyond Reality Developer Contest Official Rules…

Let’s check those more details out, shall we?

Niantic’s Real World Platform combines a world-scale persistent state engine, multiplayer AR, high-speed networking, geolocation data, and much more to create unique experiences that promote a sense of imagination and adventure. We’re seeking applicants that are excited about creating projects that follow core tenets of Niantic: exploration, exercise and real-world social interaction. The required team composition is at least five developers with experience in Unity and Java Server development.

Our focus is on games, but our definition of games is pretty expansive. So if you have an idea that bridges gaming and other areas like physical activity, social, travel or shopping, please feel free to submit. We are looking for proposals that leverage the Niantic Real World Platform’s persistent, real world capability as well as advanced AR. We encourage you to think boldly!

Well, had we the time, we’d have you do AR puzzles Tomb Raider style … inside actual ancient ruins like Angkor Wat. Help yourself, you’re welcome!

A select group of ten teams will earn a stipend and access to the Niantic Real World Platform. Finalists will work for a three-month period, with the goal of showing off their incredible work at a Demo Day in San Francisco, hosted by Niantic. In addition to regular guidance and discussion from the Niantic Engineering team, finalists will be brought to San Francisco/Bay Area to meet with executives and lay the groundwork for the work to come.

We invite you to adventure along with us, and create something that the world has never seen before…

Got some time on your hands and an indie game itch? Looks like the opportunity of the year (at least) there!

3D Touch Is Dead – Long Live Haptic Touch

So no doubt you noticed all the angst this summer about Apple possibly removing 3D Touch from iPhones, as indeed it did with the iPhone XR, if not catch up with the discussion here:

Possible Removal of 3D Touch With 2018 iPhones

… and once it actually happened, the seven usual stages of grief pretty much got dropped by most people and they headed straight to acceptance:

The iPhone XR shows how unnecessary 3D Touch has always been

Why does Apple’s 3D Touch fail miserably?

Personally, we figure the only problem with 3D Touch was discoverability, and a pretty much perfect fix was laid out here:

How Apple can fix 3D Touch

… Now that we know what the problem is, here is my solution. Like we did with the link texts years ago on the web, we should visually distinguish 3D Touchable buttons. Look at this same screen and see if you can tell which toggles accept 3D Touch … My solution is adding a line on bottom-right of things that can be 3D Touched. Let’s call them Force Decorators (with reference to Force Touch). 3D Touch is missing the most obvious thing to be mainstream. Visual cues. I think this is the answer.

Simple, elegant, and almost certainly correct; if you do support 3D Touch, consider adopting that!

However, given the lack of wrath from the buying public over the XR missing it, and the continuing Haptic Touch additions, seems like a pretty safe bet that we can consider 3D Touch a dead technology going forward … or at the very least should have parallel implementations. Which brings us to a pair of recent articles to recommend:

How to apply iOS 3D Touch to any UIView as a UIGestureRecognizer

….recently I needed to have an UIGestureRecognizer to apply to any UIView that intercepts 3D Touch as you can do with tap, drag, etc, but nothing similar is available in system libraries.
As result of my study about this implementation, I’ve written a UIGestureRecognizer subclass that can fit my needs…

Improve iOS apps user experience using Haptic Feedbacks and Taptic Engine using UIFeedbackGenerator

In my last post I wrote about introducing 3D Touch as common UIGestureRecognizer in any UIView to improve the interaction with your app, now I want to explore the haptic feedback which is giving us a new physical way to give control to the user of what is happening on his iPhone.
Until haptic feedback through taptic engine, play sounds were the only way to provide users a feedback about an action in the app, but sounds are annoying and sometimes creepy.

UIKit is providing us a clean and elegant way for that: a standard and safe interface for haptic feedbacks plug and play implementation, UIFeedbackGenerator…

If you haven’t checked out UIFeedbackGenerator before, here’s a good quick intro:

Creating an Immersive User Experience with Haptic Feedback in iOS

So, before designing your power user gesture interfaces going forward, check out those technology comparisons … and especially the 3D touch design/usability postmortems. Nothing worse than wasting time writing features that nobody actually uses!


Remember back when we first collected articles on 3D touch, and digital scale apps were a nifty thing? Guess that’s going to go by the wayside as 3D Touch falls off as well. If you do have one of those apps, maybe you want to migrate to Android — check out the state of their art in 5 Best Real Digital Scale Apps for Android!

Haptico – “easy to use haptic feedback generator with pattern-play support” 

Improve iOS apps user experience using Haptic Feedbacks and Taptic Engine using UIFeedbackGenerator


Haptic feedback in iOS apps

Captain AHAP: Custom Haptics Designer

Adding haptic feedback to your app with CoreHaptics

Haptrix — Core Haptics Designer

A Swiftcycle Built Four Two

And now that we’ve got our apps all compatible with this year’s OS and devices — you have, haven’t you? — time to take a closer look at all the goodies in the latest Swift that people have been discovering since WWDC, now that it’s official and all:

Swift 4.2 Released!

Swift 4.2 is now officially released! Swift 4.2 builds on the strengths of Swift 4, delivering faster compile times, improving the debugging experience, updating the standard library, and converging on binary compatibility.

You can watch a quick overview of it by watching the WWDC 2018: What’s New in Swift presentation, and try out some of the new features in this playground put together by Ole Begemann…

… With the completion of conditional conformance support, Swift 4.2 makes significant progress in implementing the vision of generics in the language. Watch the Swift Generics WWDC 2018 presentation for more details.

Check out those shows for sure, and read the whole thing if you want the nitty-gritty of all the implemented swift-evolution proposals, or you could just skip straight to

Migrating to Swift 4.2

Alllegedly the Xcode migrator should take care of pretty much everything, but it choked a lot for us. YMMV. Either way, not a lot of breaking changes you’re likely to find; aside from some minor renaming, check out Upgrading To Swift 4.2 for discussion, most everything new is additive — 

— and, as always, check out What’s new in Swift? for a quick and easy reference between the versions of your choice — 

— personally, our ABOUT TIME! award goes to Swift Diagnostics: #warning and #error. Good riddance, parsing scripts!

Although it’s a very close runner up for Synthesized conditional conformances in Swift 4.2. It’s just automagic!

Overdue conveniences out of the way, likely the biggest immediate aid to our coding is CaseIterable, which contrary to what the name might lead you to expect isn’t just for enums but for any type with a finite number of values: check out Enumerating enum cases in Swift for details.

Now, the biggie in terms of power, and in generating powerful opinions shall we say? centerpiece feature:

Introduce User-defined “Dynamic Member Lookup” Types

!This proposal introduces a new @dynamicMemberLookup attribute. Types that use it provide “dot” syntax for arbitrary names which are resolved at runtime – in a completely type safe way… The driving motivation for this feature is to improve interoperability with inherently dynamic languages like Python, Javascript, Ruby and others. That said, this feature is designed such that it can be applied to other inherently dynamic domains in a modular way.

On the one hand, this is definitely an “enough rope to shoot yourself in the head” kind of feature, on the other hand, Swift’s chances of ever becoming more than an Apple ghetto are enhanced significantly with this, so we figure you should all be cheering for the future job prospects! For more on this, check out

Thoughts on @dynamicMemberLookup

Exploring @dynamicMemberLookup and commentary

And while we’re speaking dynamically and all, over at Chez Wenderlich there’s an excellent overview of Dynamic Features in Swift up to and including this latest.

That’s about it for majorly interesting new stuff, but there’s some more interesting details, check out:

Ole Begemann’s above-referenced Playground: What’s new in Swift 4.2

The completely different yet identically named playground to go with Hacking With Swift’s What’s new in Swift 4.2 too.

And for yet another — come on people, we can do a creative name — Ray Wenderlich has a What’s New in Swift 4.2 three.

Michael Tsai’s Swift 4.2 Released

Finally, if you really want to get ahead of the game … check out What’s new in Swift 5.0!


Bloom Filters and Swift 4.2

How CaseIterable Works Internally in Swift

Swift Associated Types With Default Values

It’s iOS 12 Submission Day!

Just in case you missed this morning’s email, time to download the GMs and Submit Your Apps to the App Store to make launch day:

You can now submit apps that take advantage of the powerful new capabilities in the next release of iOS, watchOS, and tvOS. Build your apps using Xcode 10 GM seed, test with the latest releases of iOS 12, watchOS 5, and tvOS 12, and submit them for review.

Starting March 2019, all new apps and app updates for iPhone, including universal apps, will need to be built with the iOS 12 SDK and support iPhone XS Max. All new apps and app updates for Apple Watch will need to be built with the watchOS 5 SDK and support Apple Watch Series 4…

A relatively easy one this year for most of you we imagine, although it’s always a good idea to review Apple Platform SDK API Differences and ASCIIwwdc quickly at least. Or, y’know, bingewatch the WWDC videos while you wait for the last season of Game of Thrones or whatever.

One thing to check for specifically, if you have an iPad version that hardcodes bar heights, although you really should have learned better than that by now:

iPad Navigation Bar and Toolbar Height Changes in iOS 12

Although they didn’t make it out today, it looks suspiciously like there’ll be notched Pads in the not so distant future, doesn’t it now?

iOS 12: Notable UIKit Additions covers the minor security conveniences you’ll probably want to do a little work to take advantage of to make your users adore you.

Notifications got some fairly significant upgrades you’ll want to take a look at if you tell your users about things:

What’s new in notifications in iOS 12

New in iOS 12: Adding a Custom UI and Interactivity in Local and Push Notifications

No doubt you’ve heard of Siri Shortcuts, which definitely get the award for Niftiest 2018 New iOS Tech:

WWDC 2018 for iOS developers: Siri Shortcuts

Introduction to Siri Shortcuts in iOS 12

Shortcuts: A New Vision for Siri and iOS Automation

Speaking of nifty new tech, anyone who thought ARKit wasn’t a truly Important. Future. Direction, the advances this year should be fairly conclusive evidence of that:

ARKit 2: Bringing richer experiences through collaboration, enhanced detection, and greater realism

AR Face Tracking Tutorial for iOS: Getting Started

An Introduction to AR Quick Look in iOS 12

Saving and Restoring World-mapping Data to Create a Persistence AR Experience

Not quite as overtly nifty, but downright magical for those of us dating to when it was arguable that machines could ever learn, are the various advances relating to Core ML and its helper projects this year of Create ML and Natural Language and all:

What’s New in Core ML 2

Create ML: How to Train Your Own Machine Learning Model in Xcode 10

Training a Text Classifier with Create ML and the Natural Language Framework

Natural Language in iOS 12: Customizing tag schemes and named entity recognition

NSHipster’s NLLanguage​Recognizer and IOS 12

Creating a Prisma-like App with Core ML, Style Transfer and Turi Create

And of course there’s Xcode 10 and Swift 4.2 to learn … we’ll have updates on those too once we finish converting our projects to iOS 12 savviness!


Apple has new videos on building for the new Xes, the new Watches, and Complications

Check out the Wenderlich iOS 12 Launch Party! for new books, updated books, and $9K of giveaways!

Great UX walkthrough here for Surfacing Shortcuts

60+ great UI kits for iOS engineers has iOS 12 resources

How iOS Apps Adapt to the iPhone XS Max and iPhone XR Screen Sizes

Supporting iPhone XS Max and XR

Use x-callback-url with Shortcuts

Designing and Developing for Siri Shortcuts

Siri Shortcuts Tutorial in iOS 12

iOS12 – Password AutoFill, Automatic Strong Password, and Security Code AutoFill

iOS 12 Password Tools: Improving User Security and Experience

Push Notifications Tutorial: Getting Started

DJI Drone Development

Always one to play with fun gadgets, we picked ourselves up a DJI drone last year — like, if you own a drone, you almost certainly did too — but somehow, we’d managed to completely miss that there’s an actively supported iOS SDK suite out there, until we stumbled across this:

Automated Drone Missions on iOS

The initial idea for Dronoway, the outcome of our experiment, was to conduct automated drone missions. First of all, we chose an iOS app to control our Mavic and machine learning part (embedded in the app) to decide if the machine has enough battery to conduct the mission. If not, it should return home and continue the plan from where it stopped…

That’s an inspiring project, isn’t it? Let’s collect our resources on how to go about playing with flying toys:

Step 1: Sign up for a developer account at DJI Developer

Step 2: Check out the documentation at DJI Mobile SDK and all the sample projects:

Step 3: Integrate into your own projects, most conveniently with these CocoaPods:

  • DJI-SDK-iOS: “the DJI Mobile SDK for iOS, supporting both Objective C and Swift”
  • DJI-UILibrary-iOS 4: “a suite of product agnostic UI objects that fast tracks the development of iOS applications using the DJI Mobile SDK”

Also check all the goodies at DJI-SDK on Github — 

— in particular, note that the hardware video decoding component is found in DJIWidget here — 

and questions tagged dji-sdk on StackOverflow.

Any other fun stuff you’ve stumbled across for DJI drones? Let us know!

How To Be Evil: Guide To Violating iOS User Privacy

Remember last year there was this fuss about apps harvesting your location data and selling it? 

The curious case of Accuweather and other apps selling our location data

Well, if you were doing that, the news today is Apple’s not going to put up with it, apparently:

Apple finally decided to start enforcing guidelines on selling location data

So the question that’s no doubt on your mind today then, Dear Evil™ Readers, is: What ways are left to be Evil™ to my users?

As it happens, and this is just the strangest thing, since fastlane was purchased by Google, it seems that the main thing @KrauseFx has been working on is compiling a Manual Of How To Be Evil™:

Privacy research

I work on privacy research projects for the iOS platform in my free time. Those projects are in no way affiliated with my work or my employer…

Definitely not, we’d never suspect that! It’s not as if that employer has repeatedly needed to pay out tens of millions of dollars for privacy breaches…

oh, wait.

All kidding aside, you probably want to read through the collection of articles on that page to be aware of things that could happen to you and how to protect against them, even if you’re not planning to Use Them For Evil™ — 

— or, as may happen, inadvertently. No, seriously. In iOS Privacy: watch.user, that bit about

take pictures and videos without telling you
upload the pictures/videos it takes immediately

Yeah, that was one of the more memorable bug reports we’ve had, back in this kinda-Vine kinda-Instagram thing we worked on back in the day:

QA: Troll, why is your code uploading pictures of my girlfriend?

TROLL: Dude, my code is not uploading pictures of your girlfriend.

QA: *holds up device*

TROLL: Huh. OK … how is my code uploading pictures of your girlfriend?

(Lesson Learned there: even if you use timers only for photo countdowns, your app should listen for applicationSignificantTimeChange, or strange things may happen.)

But the one that we actually want to draw your attention today that you definitely need to read is how to protect your app from other people using it for Evil™:

Trusting third party SDKs

Third-party SDKs can often easily be modified while you download them! Using a simple person-in-the-middle attack, anyone in the same network can insert malicious code into the library, and with that into your application, as a result running in your user’s pockets.

31% of the most popular closed-source iOS SDKs are vulnerable to this attack, as well as a total of 623 libraries on CocoaPods…

… What’s the worst that a malicious SDK could do?

  • Steal sensitive user data, basically add a keylogger for your app, and record every tap
  • Steal keys and user’s credentials
  • Access the user’s historic location data and sell it to third parties
  • Show phishing pop-ups for iCloud, or other login credentials
  • Take pictures in the background without telling the user

The attack described here shows how an attacker can use your mobile app to steal sensitive user data…

And as an aid to that, there’s a repo set up now:

Trusting SDKs – HTTPs

A crowd-sourced list of SDKs and how they protect their downloads with HTTPs.

Based on the Trusting SDKs post by @KrauseFx this repo contains a crowd-sourced list of SDKs and their status when it comes to security when downloading the binary or source code…

Since you are responsible for your app’s behaviour whether the source of Evil™ is your code or your SDKs’ code, it behooves you considerably to acquaint yourself with the risks here — so read up thoroughly, and good luck with not being the next privacy-violating headline!

Swift Four -point- One And All

Looks like a particularly Good Friday today: It’s iOS 11.3 Day, which means Xcode 9.3 Day, which means we have a new Swift to learn:

Swift 4.1 Released!

Swift 4.1 is now officially released! It contains updates to the core language, including more support for generics, new build options, as well as minor enhancements to Swift Package Manager and Foundation. There was also significant progress made in stabilizing the ABI.

Doug Gregor and Ben Cohen recently discussed many of these features on a two-part episode of the Swift Unwrapped podcast. Check out the podcasts here: Part 1 and Part 2

The most code-affecting (by elimination, in the case of Equatable & Hashable!) bits are the progress on the generics front:

Swift 4.1 adds more generics features to the language, furthering the goals set out in the Swift Generics Manifesto. The following generics-related proposals have been implemented in this release:

SE-0143 Conditional Conformance
SE-0157 Support recursive constraints on associated types
SE-0185 Synthesizing Equatable and Hashable conformance
SE-0187 Introduce Sequence.compactMap(_:)
SE-0188 Make Standard Library Index Types Hashable
SE-0191 Eliminate IndexDistance from Collection

For more information about progress made with conditional conformance in Swift 4.1, check out this blog post

Do indeed check out that blog post,

Conditional Conformance in the Standard Library

The Swift 4.1 compiler brings the next phase of improvements from the roadmap for generics: conditional conformances.

This post will look at how this much-anticipated feature has been adopted in Swift’s standard library, and how it affects you and your code…

TL;DR: Things like Optionals and Arrays and Dictionaries will now be Equatable if their contents are, the way things should work!

More than TL;DR: Swift 4.1 conditional conformance is 💖AMAZING💖  and Conditional Conformance

Also, if you’d like more mapping smarts in JSONDecoder, there’s help with that:

JSONEncoder: Key strategies

The strategy enum allows developers to pick from common actions of converting to and from `snake_case` to the Swift-standard `camelCase`. The implementation is intentionally simple, because we want to make the rules predictable…

More discussion in Swift 4.1 improves Codable with keyDecodingStrategy

And the common nil-stripping application of flatMap is deprecated: Replacing flatMap With compactMap

If you‘re trying to hit a binary size target, this’ll help: Code Size Optimization Mode in Swift 4.1

That’s about it for things we’ve noticed of interest, but there’s another comprehensive roundup over at Chez Wenderlich in What’s New in Swift 4.1? — anything we missed here is no doubt in there!


compactMap for Swift < 4.1

Behind-the scenes improvements in Swift 4.1

Forcing Compiler Errors in Swift

How to use conditional conformance in Swift

What’s new in Swift 4.1? and playground

Ole Begemann’s Swift 4.1

What’s new in Swift? diffs any versions

Understanding protocol associated types and their constraints: “Swift 4.1 introduced the ability to make associated type constraints recursive: an associated type can be constrained so that it must also be of the same protocol…”

Conditional Coding with conditional conformance