Swift
Swift is a programming language created by Apple and it’s the recommended way to develop apps for Apple devices. I’ve used it to write a couple of small tools for my personal use.
5 articles
Creating a Safari webarchive from the command line
We can use the
createWebArchiveDatamethod onWKWebViewto write a Swift script that creates Safari webarchive files.Finding the biggest items in my Photos Library
A quick script to help move the biggest items out of my main Photos Library.
Snippets to manage albums in Photos.app
AppleScript only allows us to add photos to an album; dipping into Swift and PhotoKit lets us both add and remove photos.
A script to get Live Text from images
Using Apple’s built-in tools to get OCR text from an image, but without going through a GUI.
Changing the macOS accent colour without System Preferences
Updating the accent colour everywhere, with immediate effect, using a script written in Swift.
6 notes
Drawing an image with Liquid Glass using SwiftUI Previews
I used Xcode to create an image with a Liquid Glass effect, then I used the Preview to export it as a standalone file.
How to get a macOS file/folder icon in Swift
Use
NSWorkspace.shared.iconto get the icon as anNSImage, then you can save it to disk or do something else with it.How to check the quality of a network connection
Using an
NWPathMonitorand inspecting the value ofNWPath.status,NWPath.isExpensiveandNWPath.isConstrainedcan tell you what sort of connection you’re running on.Writing a file in Swift, but only if it doesn’t already exist
Adding
.withoutOverwritingto yourwrite()call will prevent you from overwriting a file that already exists.How to delete albums
How to profile Swift code