Unlock This Episode
Our Free plan includes 1 subscriber-only episode of your choice, plus weekly updates from our newsletter.
Introduction
We can make all of this much better if we finally take control over our dependency on the file system. In particular, the saving and loading of data to the file system.
Our Dependencies library does not come with such a client immediately available to us, but it is quite easy to create. This will give us a chance to show off how one registers a new dependency with the library so that it is immediately available everywhere via the @Dependency
property wrapper.
Subscribe to Point-Free
Access this episode, plus all past and future episodes when you become a subscriber.
Already a subscriber? Log in
Exercises
Use
@Dependency(\.speechClient.authorizationStatus)
in the standup detail view to show
alert when authorization has been denied.Further, add an alert button action that uses
@Dependency(\.openURL)
to go to the
application notification settings.Use
@Dependency(\.date)
and@Dependency(\.uuid)
to take control of all instances of
Date()
andUUID()
in the application.Write a test for the record screen that confirms that the timer pauses when the end meeting
alert is presented. Use a test clock to show that when the alert is up, theelapsedSeconds
state does not change when the clock is advanced. Dismiss the alert, advance the clock, and
assert that the timer continues.Write a test for the deletion flow of a standup. Start the test off in a state with at least
one standup, and simulate drilling down to the detail, tapping the delete button, assert
that an alert was shown, simulate tapping the confirm deletion button, and then assert that
the screen popped back to the root and the standup was removed from the collection.Let’s beef up the static
DataManager.mock
method to support accessing data from more than
one URL in a test. Instead of wrapping a mutable blob ofData
, wrap a[URL: Data]
dictionary instead.Let’s further beef up the
DataManager
dependency. Define a statictestValue
that calls
XCTFail
by default. Then, defineoverride
methods that bypasses failure on a per-URL
basis.
References
Getting started with Scrumdinger
AppleLearn the essentials of iOS app development by building a fully functional app using SwiftUI.
Standups App
Brandon Williams & Stephen CelisA rebuild of Apple’s “Scrumdinger” application that demosntrates how to build a complex, real world application that deals with many forms of navigation (e.g., sheets, drill-downs, alerts), many side effects (timers, speech recognizer, data persistence), and do so in a way that is testable and modular.
CasePaths
Brandon Williams & Stephen Celis • Monday Aug 23, 2021Custom Dump is one of our open source projects. It provides a collection of tools for debugging, diffing, and testing your application’s data structures.
SwiftUI Navigation
Brandon Williams & Stephen Celis • Tuesday Sep 7, 2021A library we open sourced. Tools for making SwiftUI navigation simpler, more ergonomic and more precise.
combine-schedulers
Brandon Williams & Stephen Celis • Sunday Jun 14, 2020An open source library that provides schedulers for making Combine more testable and more versatile.
CasePaths
Brandon Williams & Stephen CelisCasePaths
is one of our open source projects for bringing the power and ergonomics of key paths to enums.
Clocks
Brandon Williams & Stephen Celis • Wednesday Jun 29, 2022An open source library of ours. A few clocks that make working with Swift concurrency more testable and more versatile.
Dependencies
Brandon Williams & Stephen Celis • Sunday Jan 9, 2022An open source library of ours. A dependency management library inspired by SwiftUI’s “environment.”
Identified Collections
Brandon Williams & Stephen Celis • Sunday Jul 11, 2021Identified Collections is our open source library that provides an ergonomic, performant way to manage collections of identifiable data, and fits in perfectly with SwiftUI.
Tagged
Brandon Williams & Stephen Celis • Monday Apr 16, 2018Tagged
is one of our open source projects for expressing a way to distinguish otherwise indistinguishable
types at compile time.
XCTest Dynamic Overlay
Brandon Williams & Stephen Celis • Wednesday Mar 17, 2021XCTest Dynamic Overlay is a library we wrote that lets you write test helpers directly in your application and library code.
Packages authored by Point-Free
Swift Package IndexThese packages are available as a package collection, usable in Xcode 13 or the Swift Package Manager 5.5.