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 !!!
Finally, the swift-snapshot-testing from @pointfreeco was updated with important fixes, including the famous Intel vs M1 problem 🎉 Happy for my first contribution as well ☺️
— Nuno Vieira 🇵🇹🇺🇦 (@nunovieira_dev)
Sep 22, 2022
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.
Introducing Prism, a library for animating 3D shapes. Made with 100% SwiftUI:
— Andrew Zheng (@aheze0)
Sep 27, 2022
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
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 😊
SwiftFormat from @nicklockwood has nowadays a SPM artifact bundle attached to its GitHub release 👍
Super easy to use SwiftFormat in a Swift Package Command Plugin.
In Xcode 14 you can use such plugin even on an Xcode project.
Let me know if you are interested in the code.
— Marco Eidinger 🧑🏻💻 (@MarcoEidinger)
Jul 15, 2022
Learn about the open-source Swift Package Command Plugin SwiftFormatPlugin that uses the popular SwiftFormat command-line tool