• Extensible API in Swift

    A Swift enumeration case lets you clearly spell out a mode of operation in the call site of a function. The downside is that by their nature they are “closed” and can’t be extended from outside the library they are declared. Once you define then, that’s it, they can’t be extended without another release. Recent additions to Swift 5.5 give you more tools fore creating API that is both ergonomic and extensible.

  • R-Style Boolean Sequences in Swift

    One of the great things about the R statistical programming languages is it’s ability to operate on vectors of values. I got to thinking, wouldn’t it to be great to have this capability in Swift? Well, Swift is nice that way. Swift gives you a lot of flexibility to morph the language.

  • Swift Concurrency Notes

    Notes reading the async/concurrency proposals to be introduced in Swift 5.5. Before you can play chess well, you must first learn the rules of chess.

  • Fluent with SwiftUI

    Apple’s CoreData is a great choice for a data model on iOS and with SwiftUI. Under the hood it uses SQLite to handle lots of data that can’t fit into memory all at once. I have always wondered about using SQLite directly. It would be a little messy because SQLite is a C library and it would force you to use the unsafe APIs that you would certainly want to wrap. It turns out that you can pretty easily use the ORM from the Vapor project in your SwiftUI project. I prepared this example by looking at test code.

  • Property Wrappers

    Swift 5.4 is now released and includes language improvements and tooling improvements. Paul Hudson, as usual, has a great summary of what is new hosted at https://www.whatsnewinswift.com.

  • SwiftUI with Argument Parsing

    It’s easy to apply the Swift Argument Parser in the last post to a SwiftUI app. This capability can be helpful in testing by allowing you to bootstrap data into your app. In this post, you will take a minimal SwiftUI app and add argument parsing to it. Here is the app greeting that shows a greeting message to the user.

  • Command Line Tools in Swift

    Command-line interfaces (CLIs) provide a robust, textual way to communicate with your programs. Swift, as a general-purpose computing platform, lets you build these kinds of tools efficiently and elegantly. In this post, you’ll have a look at the Swift package Argument Parser, which handles all the boilerplate of creating a full-featured, command-line interface.

subscribe via RSS