Open Source Updates for Swift Projects - Issue #6 - Jump

Welcome to the six issue of the bi-weekly newsletter “Open Source Updates for Swift Projects”. Learn about new projects and innovations of popular projects that help you as a Swift / iOS developer.

I’d love to receive your input and suggestions to include in this newsletter. Please share them with me via email.

Easier UI testing with Snapshot tests

swift-snapshot-testing from Point Free, the same folks who implement TCA, is a library that allows testing views and view controllers against previously recorded snapshots (images or textual representation).

It is a great addition to conventional UI tests and it is perfect to identify UI regressions. SnapshotTesting isn't limited to views and view controllers! There are a number of available snapshot strategies to choose from.

The latest release 1.1.0 has a minor breaking change (renamed package) and CocoaPods / Carthage support was deprecated (long live SPM) but you should see significant performance improvements (90+%) thanks to a new perceptualPrecision option, which can be used to support snapshot tests across Intel and M1 devices !!!

3D rendering in SwiftUI

Prism is just a couple of days old but iOS developers are excited on Twitter and its GitHub repository has nearly 400 stars.

Prism is a lightweight 3D renderer for SwiftUI.

  • Works with any SwiftUI View.

  • Fully interactive and animatable.

  • Compatible with all SwiftUI modifiers.

  • Will not affect sizing (unlike GeometryReader...)

  • 100% SwiftUI. No SceneKit or other weird stuff.

  • Powered by perspective transforms, so it's fast.

  • Supports sizing, extrusion, levitation, and more.

The example app includes a bunch of samples to play with. 

Logic-less templates with Mustache

GRMustache extends the genuine Mustache language with built-in goodies and extensibility hooks that let you avoid the strict minimalism of Mustache when you need it.

let template = try Template(string: "Hello ")

  • Support for the full Mustache syntax

  • Filters, as 

  • Template inheritance, as in and mustache.php.

  • Built-in goodies

  • GRMustache.swift does not rely on the Objective-C runtime. It lets you feed your templates with ad-hoc values or your existing models, without forcing you to refactor your Swift code into Objective-C objects.

The latest release 4.1.0 might be more exciting for its contributors as swift-tools-version 5.3 was adopted that supports resources and enabled the team to run tests through SPM.

I merely use this opportunity to introduce a mature library to handle Mustache templates in Swift.

Code formatting with SwiftFormat

SwiftFormat from Nick Lockwood is my favorite code library and command-line tool for reformatting Swift code.

SwiftFormat goes above and beyond what you might expect from a code formatter. In addition to adjusting white space it can insert or remove implicit self, remove redundant parentheses, and correct many other deviations from the standard Swift idioms.

The latest version 0.50.0 adds quite some improvements to keep up with Swift 5.7 innovations.

  • Added genericExtensions rule for simplifying conditional type extensions in Swift 5.7

  • Added markTypes support for type definitions in extensions

  • Added opaqueGenericParameters rule to use opaque generic parameter syntax where equivalent

  • Added blankLineAfterImports rule

  • Added redundantOptionalBinding rule for simplifying if let expressions in Swift 5.7

And if you are wondering if you can SwiftFormat as a Swift Package Command Plugin: yes 😊

Learn about the open-source Swift Package Command Plugin SwiftFormatPlugin that uses the popular SwiftFormat command-line tool