Under The BridgeUnder The Bridge

Musings
Join The Dark Side We Have WebCookies

Here is an excellent reference to keep handy for your next project … or when you’re finally getting that proper iOS 13-savvy redesign finished up for your current projects, not that any of us would be in that situation of course:

What a Designer Needs to Know about iOS Dark Mode When Working with a Developer

As a senior iOS app developer, it is my responsibility to analyse an app UI / UX design from a developer standpoint and provide feedback to the designers. One of the common problems that my team encounter is the communication gap between designers and developers, because of that, designers sometimes might create UI / UX design that is impossible or extremely difficult to implement by the technical team…

Feeling the pain? We know we’re feeling the pain.

With the introduction of dark mode in iOS 13, Apple has redefined the meaning of colors and UI styling in iOS, which further widen the communication gap between designers and developers. This has motivated me to create this article that from a technical perspective, explain what a designer need to know regarding adopting iOS dark mode in order to smoothen the communication between both parties…

And it is an excellent job of doing so!

More good reads for your designers are

How to design delightful dark themes

It is difficult to create a delightful dark theme. We cannot simply reuse our colors or invert our shades. If we do, we will achieve the opposite of what we want: we will increase eyestrain and make it harder to read in low light. We may even break our information hierarchy.

In this post, we share how to design dark themes that are readable, balanced, and delightful….

8 Tips for Dark Theme Design

When it comes to designing a dark theme for an existing app, you probably want to communicate the same spectrum of emotions in dark mode. But it’s better not to do it. Why? Because colors are actually perceived differently depending on their background…

Dark UI Design: A step-by-step guide

What’s New in iOS Design and Implementing Dark Mode on iOS

From the implementation side of things, here’s some articles worth reading for various tips and tricks:

Implementing iOS 13 Dark Mode in the new BigCommerce mobile app

Implementing Dark Mode on iOS

Implementing Dark Mode in iOS 13 (Instagram)

How To Adopt Dark Mode In Your iOS App

iOS 13 Dark Mode and companion DarkMode helpers

Dark Mode: Adding support to your app in Swift

Dark Mode on iOS 13

iOS 13 Semantic UI: “Dark Mode, Dynamic Type, and SF Symbols”

DynamicColor is “Yet another extension to manipulate colors easily in Swift and SwiftUI”

Backward compatible Dark Mode on iOS

Implement In-App Dark Mode Using Swift Observation Protocols

Mobile App Security: CryptoKit Your Critical Kit

Here’s a set of posts that you should make some time to read if you’re any kind of mobile developer, not because there’s anything strikingly new here — in fact, hopefully there isn’t! — but just to be sure that you have a good basic grounding in 2020’s app security requirements, both for iOS and that other platform:

Mobile App Security: Best Practices on Android & iOS

Android App Security: Best Practices

iOS App Security: Best Practices

Smartphone apps are the center of most peoples’ technology usage. They deal with a lot of private and sensitive user data like your personal health information or banking information. Protecting this data as well as possible is heavily important and the topic of this article.

In this article, we focus on iOS App Security. We’ll show you concrete techniques for making your iOS apps more secure. Our best practices cover means for securely storing data as well as sending & receiving data over the network. You’ll see why it is so hard to get security right and how you can improve your app security by using services from Apple and other providers…

Most of this hasn’t changed much since the last time we did any posts about security here 8-10 years ago, so it should pretty much be a refresher for you, with the possible exception of what you might have overlooked with all that actually exciting stuff out of last year’s WWDC:

Apple’s CryptoKit is a new API that was introduced in iOS 13 and provides lower-level APIs to perform cryptographic operations or implement security protocols.

CryptoKit is based on top of more lower-level APIs. They were available before but introduced additional risk factors since developers often used them in a wrong way.

CryptoKit also allows you to use the SecureEnclave to get cryptographically safe functions that are performant and optimized for the device’s hardware…

So that’s pretty much a solid win all around there, isn’t it? Next time you’re touching crypto stuff, do yourself and the rest of the ecosystem a favor and adopt it! Isn’t a great deal of resources out there, but here’s what we’ve noticed:

WWDC session 709: Cryptography and Your Apps and associated playground

Discover the New Apple CryptoKit Framework

Common Cryptographic Operations With Cryptokit

When CryptoKit is not Enough

CryptoKit and the Secure Enclave

Particularly that last one, if you want really really secure:

For us developers, how the Secure Enclave deals with biometrics is not the most exciting part about it, because we cannot query it directly. Even our biometric APIs are constrained and they are fully handled by the system, so we cannot really do much work on top of that. The real exciting thing is that we as developers can leverage the Secure Enclave to encrypt and decrypt information with keys that are specific to a specific setup in a specific device…

And that’s about it for state of the art security. For your non-up-to-date users, their recommendation is

If you want to support older iOS versions you can use those lower-level APIs or use well known open-source third-party libraries like CryptoSwift.

That one does look pretty much the most comprehensive to us at the moment as well, yep; but there’s a wide variety of libaries in this space with varying focuses, so we’ll just point you at the currently best maintained curated lists with applicable sections — those links should stay relevant for another decade we trust!

Awesome iOS: Security

Awesome Swift: Security

UPDATES:

Introducing Swift Crypto

Swift Crypto is a new Swift package that brings the fantastic APIs of Apple CryptoKit to the wider Swift community. This will allow Swift developers, regardless of the platform on which they deploy their applications, to access these APIs for a common set of cryptographic operations…

Core ML 3: How To Train Your Device Model

So things have certainly been moving right along since last we posted in 2017 in the iOS machine learning world haven’t they? Whilst we have our accustomed healthy skepticism of the frothily wild-eyed claims of The Universal Panacea Of Machine Learning you see floating around — 

CONCERNED PARENT: If all your friends jumped off a bridge, would you?

MACHINE LEARNING ALGORITHM: “YESSSS!!!!”

— this new being able to train models on our devices thing as well as all the other new stuff in CoreML 3 is a bit of a tipping point from “curiosity” to “something to think of serious applications for” we’d say!

If you haven’t taken much notice of the lingo so far and need some bringing up to speed, check out this course list from our friends at CourseDuck

The World’s Best Machine Learning Courses & Tutorials in 2020

And if you want lots and lots and lots of cross-platform machine learning resources, check out the awesome list

Awesome-Mobile-Machine-Learning

But we’re focusing on the device training today, and from what we can tell the reigning authority in that space is Matthijs Holleman’s blog, most notably the four piece series On-device training with Core ML completed last month:

  1. Introduction to on-device training
  2. Rock, Paper, Scissors (Lizard? Spock?)
  3. k-Nearest Neighbors
  4. Training a Neural Network

For sure read that whole series, and check out the rest of the blog too, we particularly liked

Core ML and Combine

And now you have a Combine processing chain that, every time you send it a UIImage object with imagePublisher.send(image), will automatically run a Core ML model on that image and process the results. Pretty cool!

And if you like those enough to pay for more, he’s got not just one but two books out: Machine Learning by Tutorials and Core ML Survival Guide — which we’re pretty sure makes him the go-to guru of iOS machine learning!

Other good introductions to new features and related goodies:

Working with Create ML’s MLDataTable to Pre-Process Non-Image Data

4 Techniques You Must Know for Natural Language Processing on iOS

Face Detection and Recognition With CoreML and ARKit, and Snapchat For Cats

Advancements in Apple’s Vision Framework: 2019 Year-in-Review

Text recognition on iOS 13 with Vision, SwiftUI and Combine

Build a Core ML Recommender Engine for iOS Using Create ML

MakeML’s Automated Video Annotation Tool for Object Detection on iOS

And here are some examples of classifiers and detectors we figure look useful, interesting, or just amusing:

Sound Classification on iOS Using Core ML 3 and Create ML

How to Build a Song Recommender Using Create ML MLRecommender

Building a Fake News Detector with Turicreate

Using Core ML and Natural Language for Sentiment Analysis on iOS

Detecting Pets with the iOS Vision Framework

iOS Build Cat Vs Dog Image Classifier Using Vision In 5 minutes

Photo Stacking in iOS with Vision and Metal

Using Sky Segmentation to create stunning background animations in iOS

And in that last category, our Machine Learning Rise Of Skynet Award goes to

Building a Face Detecting Robot with URLSessionWebSocketTask, CoreML, SwiftUI and an Arduino

Some time ago I created a little side project that involved an Arduino-powered servo motor that menacingly pointed at people’s faces with the help of CoreML, mimicking the Team Fortress 2 Engineer’s Sentry Gun. With iOS 13, I decided to re-write that using the new Socket APIs and SwiftUI…

“Mimicking,” he says now, but just you wait…

UPDATES:

How to make your iOS app smarter with sentiment analysis

2020 iOS Conference Calendar

And as we begin another glorious year of iOS development, time to start planning our conference visits and talks for this year! Actually, it’s already closed for the earlier ones, so this year we’re going to expand our listings with the latest known CFP, so you can get an early start on planning next next year’s schedule too!

And if you haven’t given a talk before and don’t know where to start, we recommend you check this out:

How to deliver a talk at a programming conference

And if you’re really really serious about this conference thing, check out this dude:

What I’ve learned after sending 147 proposals to 36 conferences in a year

An inspiration to us all!

JANUARY: 

FEBRUARY:

  • 3: dotSwift — Paris, France — CFP
  • 12-13: MGS20 — San Francisco, US — see website 
  • 20-21: MobOS — Cluj-Napoca, RomaniaCFP closed 11.15

MARCH:

  • 2: QCon — London, UK — see website
  • 10-13: Appdevcon — Amsterdam, Netherlands — CFP closed 12.01
  • 12: T3chFest — Madrid, Spain — see website
  • 12-13: Mobile Trends — Krakow, Poland — see website
  • 18-20: try! Swift — Tokyo, Japan — CFP
  • 19-20: iOSCon— London, UK — CFP closed 11.06
  • 24-25: MacAdUK— London, UK — see website
  • 28: CodeFest— Novosibirsk, Russia — CFP
  • 30-April 1: MobileTechCon — Munich, Germany — see website

APRIL:

  • 9: QCon — Beijing, China — see website
  • 15-17: Devoxx — Paris, France — CFP
  • 16: MGS Singapore — Singapore — see website 
  • 27-29: GOTO Chicago— Chicago, US — see website 
  • 28-29: CodeMobile— London, UK CFP closed 11.15
  • ??: NSNorth— Montreal, Canada — see website 

MAY:

JUNE:

JULY:

AUGUST:

SEPTEMBER:

  • 6-9: iOSDevUK— Aberystwyth, UK — see website 
  • 16-17: MGS Europe — Berlin, Germany — see website 
  • ??: NSSpain Logroño, Spain — see website 
  • ??:  /dev/world — Melbourne, Australia — see website 

OCTOBER:

  • 7-8: SwiftLeeds — Leeds, UK —  see website
  • 7-8: Canvas — Birmingham, UK — see website 
  • 8-9: UXDX — Dublin, Ireland — CFP 
  • 19-21: QCon Munich — Munich, Germany see website 
  • ??: FrenchKit — Paris, France — see website 
  • ??: #Pragma— Bologna, Italy — see website 
  • ??: GOTO Berlin— Berlin, Germany  see website
  • ??: Swift by Northwest— Portland, US  see website
  • ??: Mobiconf Krakow, Poland — see website 
  • ??: Server-Side Swift Copenhagen, Denmark — see website 

NOVEMBER:

  • ?? Swift HeroesTurin, Italy — see website 
  • ?? Swift AlpsCrans-Montana, Switzerland — see website 
  • ?? BA: SwiftableBuenos Aires, Argentina — see website 
  • ?? Swift & FikaStockholm, Sweden — see website 
  • ??: Mobile EraOslo, Norway see website 
  • ??: NSBrazilSão Paulo, Brazil see website 
  • ??: GOTO Copenhagen— Copenhagen, Denmark  see website

DECEMBER:

  • ??: heise MacDev— Karlsruhe, Germany  see website
  • ??: DevTernity— Riga, Latvia  see website 
  • ??: KotlinConf— Copenhagen, Denmark  see website 

 

Other resources to keep an eye on as the year progresses:

CocoaConferences

Find your next tech conference

Tech Events Online

The Best Swift and iOS conferences in 2020

The Complete List of Mobile (iOS and Android) Conferences in 2020

And a presentation tip for those code snippets!

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!

UPDATES:

Using Swift’s CombineLatest Effectively

Black Friday Deals 2019

Seems like the Black Friday deals get a little earlier each year don’t they? In fact, we’re hurrying this post out because there’s eight hours fifty-three minutes left in a Black Friday deal that, in fact, ends Wednesday morning:

Black Friday 2019 — special offers on Pixelmator apps

Starting today, you can get the amazing Pixelmator Pro for 25% off. This discount will be available for a week, until December 3rd. In addition, Pixelmator Photo, our incredible photo editor for iPad, is completely free for 24 hours until 9am ET, November 27th. Spread the word!

So hurry on over to App Store on your iPad and grab that.then

… and speaking of free stuff, Packt has not only the usual discounts pretty much everybody that does e-learning has on but a completely free week as well, so if you haven’t got an account there now’s a particularly good week for it! 

… and speaking of e-learning, looks like the $99 a year subscription is going to be a regular thing over at 

raywenderlich.com Black Friday Sale: $99/year Subscriptions and More!

Of which there’s enough there this year on SwiftUI and Combine and all that new stuff we need to get up to speed on right quick that we finally figured it was likely worth shelling out for a subscription this year, recommend you seriously consider it too!

As usual, there’s a macOS / iOS developer focused deals repo up on Github

💰💸💰 Black Friday Deals 💰💸💰 

And Michael Tsai has deals on his own apps and a roundup here!

Black Friday 2019

This Xcode Goes To 11

Well, this has been a particularly exciting year on the Xcode front, hasn’t it?

  • Xcode 11 supports development with SwiftUI
  • SwiftUI live views and inline results in playgrounds are supported…
  • Xcode 11 adds support for Mac Catalyst to bring iPad apps to the Mac…
  • Xcode now supports creating and working with Swift packages, as well as adding, removing, and managing package dependencies…
  • An XCFramework makes it possible to bundle a binary framework or library for multiple platforms…
  • The new Metrics organizer shows battery life and performance analytics for your app to help you drive optimizations…
  • Xcode 11 supports the new Apple Development and Apple Distribution certificate types. These certificates support building, running, and distributing apps on any Apple platform…
  • Metal is available in iOS 13 and tvOS 13 simulators when running on macOS 10.15…
  • Introduces the ability to view inline code diffs for changes in the Source Editor…

Not sure “particularly exciting” covers it actually, this is the biggest Xcode update in the history of ever far as we can remember! Read the whole thing, and then the latest point release notes up to 11.3 Beta as we type this; and here’s a couple particularly good visual-enhanced tours of the new goodies:

Xcode: All the Way to 11

What’s new in Xcode 11? [Updated for 11.1 and 11.2]

Personally, this version of Xcode is a veritable benediction, given how many years we’ve been desperately looking forward to disposing of third party dependency managers…

Ready for Swift Package Manager?

Replacing CocoaPods with Swift Package Manager

Launching the SwiftPM Library + SwiftPM Catalog

…and once more being able to use workspaces as actual, y’know, workspaces. We’re not quite there with our latest project — the last serious roadblock is Firebase requiring binary framework support — but we are very close indeed! Mind you, we did have to do some considered refactoring to dispose of some pods that weren’t Pure Swift™, there’s a good if overly despondent summary of the various existing drawbacks here:

Dependency Heck

The state of iOS dependency management in 2019 is not great, and might get worse before it gets better…

Although we disagree with that completely, it’s orders of magnitude better than Xcode 10 even with the loose ends lying about still and getting better by the day, we say! In the meantime, aside from the third party dependency migration pains, even more important in the future is it’s much easier now to manage your internal dependancies and modularity with SPM:

Update your existing iOS Framework to Swift Package

Creating Swift Packages in Xcode + Editing A Swift Package

Managing dependencies using the Swift Package Manager

And that’s about enough for SPM for now. Next thing we’d like to highlight from that intro list is what drives that Metrics organizer, in case you’d overlooked it so far:

MetricKit

With MetricKit, you can receive on-device app power and performance metrics captured by the system. A registered app receives reports containing data about the previous 24 hours at most once per day…

Introduction at Improving Battery Life and Performance

NSHipster has a deeper dive in Metric​Kit

And for a really deep dive, check out MetricKit Internals!

SwiftUI and Catalyst are going to require some deep, deep diving of their own; for now, we’ll list miscellaneous other new and old Xcode tips we’ve collected since The Xth-Code Files: Xcode 10 Tips:

one small change for xcode, one giant leap for productivity

XCode allows you to take a snapshot of the state of the app you are developing and restore it later when you run the app or run the tests. Pretty cool!

Xcode 11 environmental overrides

Have you used the accessibility inspector to change the dynamic type size of your running app? Did you know you can do that directly from the debugger with Xcode 11? Even better, it allows you to override the interface style to quickly switch between light and dark modes…

Sherlock turbocharges your iOS simulator

There aren’t many times outside of WWDC where Apple developers see a new tool and immediately think “I need that in my life.” Sherlock by Inspired Code is one such tool: it injects itself into the iOS Simulator so that it can monitor views and adjust them in real time…

NSHipster’s simctl has Simulator tips you really want to know about

Better Storyboards with Xcode 11

Using Xcode Previews with existing views without using SwiftUI

Add a View <> ViewModel Jump To Counterpart

XCAssetsKit: “.xcassets parser written in Swift”

QuickLook plugin to visualize .car files (compiled Asset Catalogs)

Speeding up with Xcode Behaviors

Awesome-Xcode-Behaviors

The fastest way to Xcode: “Using the power of aliases in your Terminal”

Xcode: Basics of the four-block wonder aka “Navigate to Related Items”

37 Xcode Tips and Shortcuts to speed up your daily development

Unused images and resources clean up in Xcode

Unused localized strings clean up from a Strings file

Variable Width Strings

Where the &$!#% Is Localizable.Strings?!?

PoeditApp: “The fastest and most convenient way to translate apps & sites with gettext”

Periphery: “A tool to identify unused code in Swift projects.”

Streamlining your development workflow with Xcode Templates

ios-project-template: “iOS project template with fastlane lanes, Travis CI jobs and GitHub integrations of Codecov, HoundCI for SwiftLint and Danger”

Building Faster in iOS with Bazel

Project generation: Introduction to development of Tuist: “Bootstrap, maintain, and interact with Xcode projects at any scale”

And finally, to remind us that not quite everything is better these days:

Xcode​Kit and Xcode Source Editor Extensions

When we last wrote about extending Xcode in 2014, we were living in a golden age, and didn’t even know it…

Ah well. There’s still some good ones out there — our Most Useful™ Award goes to

SwiftMockGeneratorForXcode — An Xcode extension (plugin) to generate Swift test doubles automatically.

Check it out!

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!

UPDATES:

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!

Kowalski, Analytics!

So it’s been a little while since we last looked at analytics for your iOS app, and as it happens we have a new one just out that could use some sober second thought on its analysis strategy going forward; let’s take a look at that today, shall we?

Kowalski

 

First off, since you don’t have to do any work to get them it’s always a good idea to keep abreast of the latest developments in App Store Connect App Analytics – especially since there’s a bunch there that you can’t get with any other service! But, since you can’t report any custom events so they’re not very interesting development-wise, we’ll just remind you of the documentation and move right along, to consider in detail the current crop of services that are FREE! and UNLIMITED! that being the tier of service that us scrappy Indies are most interested in naturally!

So, last time we were checking out this analytics thing, the buzz was all about Fabric Answers

The best of Answers realtime analytics is now part of Firebase. New apps should use Google Analytics for Firebase…

Well then. How about that old standby for website centric organizations, Google Analytics? Oh, look they’re shutting that down too this Hallowe’en…

To use the latest generation of app reporting in Google Analytics, you’ll need to install the Firebase SDK. If you do not have a Firebase project, go to firebase.google.com to get started. Once you have completed the setup, return to Google Analytics…

Huh. OK, if you’re tied into the Google ecosystem, or anything that was good it acquired, it seems your choice is very clear. Singular, in fact!

Personally, we’d prefer not to be tied into the Google ecosystem, particularly if we’re not depending on it for anything besides analytics, so we’ll leave the Firebase option off the table as long as possible. Besides, it isn’t completely free, although the free usage limits are generous.

For completely free to the developer, Flurry appears to still be the leader in app support suites, with push and real time analytics and advertising and remote config and all sorts of other goodies these days; come a long way since Peter Farago stopped by to say thanks for our first note on it over ten years ago and now he’s “GM & VP Flurry” at Verizon with a job description of “Making Flurry awesome(r)” so that would seem to indicate that it’s weathered its various acquisitions nicely and continues to be a solid choice going forward.

While we were developing this last project, we tried out Visual Studio App Center and were reasonably pleased with it in general — we didn’t get around to creating any specific events, but even the default session monitoring of App Center Analytics is providing useful information — it’s still maturing, but if you’re tied in to Microsoft platforms or the slowly migrating HockeyApp, this is the support suite for you! Without that, it doesn’t have a compelling use case … aside from being Not-Google. Should you find that compelling.

Another option, if you have a Facebook app as pretty much everyone does these days, is Facebook Analytics where if you’ve linked in the Facebook SDK you can see session info in Facebook’s Event Manager things logged with App Events for iOS. Not actually real time though, and you don’t get the push notifications and crash reporting and so forth of the above suites, so picking one of them is probably what most of us will be interested in. 

Now, there are a veritable plethora of other analytics services out there that don’t meet the FREE! and UNLIMITED! test, any number of which may be suited enough to your particular needs to be worth their investment: here’s a few of the better recentish roundups we looked at putting together post, check them out if you have a budget:

The Apps Have Spoken: Top 13 iOS App Analytics Platforms [2019]

Top 11 Mobile App Analytics Platforms in 2019 (Pricing Included)

Top 20 Mobile App Analytics Tools: Which is the best one for you?

Top App Analytics Tools (2019)

And if you don’t want a service at all but want to host your own analytics, an excellent start on that is this:

Countly Community Edition
Your very own, self hosted and open source desktop, web, mobile analytics server and SDKs

At least it looks like it. We wouldn’t know. We’re not into self-hosting or rolling our own of anything we can possibly get away with not. But if you are, check it out and let us know how that goes for you!

And finally, whichever one of these alternatives you pick first, it’s a solid bet that you’ll be called on to change it at some point, because that’s just the way it always works, isn’t it? Here is a nicely elegant post about creating

A modular analytics layer in Swift

We are going to build a layer that avoids using a static API, puts any backend APIs behind a protocol, uses the power of Swift enums and pairs each event with the pieces of data it needs to contain.

More specifically it should:

  • Be easy to report new and existing events.
  • Allow the data be sent to whichever analytics backend we wish to use, even multiple.
  • Be testable and mockable, allowing it to be an injected dependency.
  • Allow events to be reported from anywhere in the app, but encourage best practices.
  • Have compile-time safety of events and their properties…

Sounds like just about the way we like to put service wrappers around our dependencies yep — so whatever analytics you choose, check that out!

UPDATES:

8 Critical KPIs for Your App and How to Track Them

Assertions in Production for tracking internal errors

SmartlookConsentSDK for getting user consent