This is the support document for my online presentation at for MacSysAdmin Online in October 2021.
- Slides are available as a Keynote document (a large fraction of the slides are actually movies)
- Video (All MacSysAdmin Online 2021 sessions)
“New Chooser” icon by Mischa van der Bent, who also helped a lot (as usual) to make the slides look much better.
I am not arguing you should use Swift for everything. I discussed which tool to use for what kind of jobs in my 2019 session “Moving to zsh.”
Update October 2022: With the release of macOS Ventura Apple has removed the deprecated LaunchServices functions. The replacements are now methods of the NSWorkspace object. When you want to use these functions in a way that is compatible older versions of macOS you have to use the LaunchServices functions on Big Sur and older and the NSWorkspace functions on Monterey and higher. I have updated the LSKit.swift file in the gist to use the appropriate functions, depending on the version of macOS the app is running on.
Swift 2: Let’s Swift again!
- Swift for Apple Admins Presentation – MacSysAdmin Conference 2018
- Resource Files (GitHub Gist)
- scriptingosx/MSA-Demo-Chooser (completed project)
Swift Progress
- WWDC ’21: What’s new in Swift
- The Swift Programming Language (Swift 5.5)
- Swift 5.5 Released! – Swift.org Blog
- Concurrency — The Swift Programming Language (Swift 5.5)
- WWDC ’21: Meet async/await in Swift
Swift Organization Packages
- apple/swift-numerics – GitHub
- apple/swift-argument-parser – GitHub
- apple/swift-system – GitHub
- apple/swift-crypto – GitHub
- apple/swift-atomics – GitHub
- apple/swift-algorithms – GitHub
- apple/swift-collections – GitHub
- apple/swift-nio – GitHub
SwiftUI
- WWDC ’21: What’s new in SwiftUI
- WWDC ’21: SwiftUI on the Mac: Build the Fundamentals
- WWDC ’20: Introduction to SwiftUI
Command Line Tool
- Launch Services – Developer Documentation
- NSWorkspace (scroll all the way down on the NSWorkspace page until you get to “Instance Methods” which shows the new macOS 12 Monterey . For compatibility with Big Sur, we still use the deprecated Launch Services functions in this demo)
- How to check for valid method input using the guard keyword – Hacking with Swift
- Type Casting – The Swift Programming Language (Swift 5.5)
- URL – Developer Documentation
- Resource Files (GitHub Gist
- Writing Symbol Documentation in Your Source Files – Developer Documentation
- CommandLine – Developer Documentation
- apple/swift-argument-parser – GitHub
- swift-argument-parser/Documentation at 0.5.0
- Property Wrappers — The Swift Programming Language (Swift 5.5)
SwiftUI Application
SwiftUI
- WWDC ’21: What’s new in SwiftUI
- WWDC ’21: SwiftUI on the Mac: Build the Fundamentals
- WWDC ’20: Introduction to SwiftUI
- Introducing Swift UI – Apple SwiftUI Tutorials
- SwiftUI – Developer Documentation
Building the App
- Building Layouts with Stack Views – Developer Documentation
- How to create views in a loop using ForEach – Hacking with Swift
- Why does .self work for ForEach? – Hacking with Swift
- Extensions – The Swift Programming Language (Swift 5.5)
- WWDC ’20: Visually edit SwiftUI views
- Ternary Conditional Operator – The Swift Programming Language (Swift 5.5)
- Combine – Documentation
- WWDC ’20: Data Essentials in SwiftUI
Managed Preferences
- Preferences Utilities – Developer Documentation
- UserDefaults – Developer Documentation
- AppStorage – Developer Documentation (yes, this doc is quite useless)
- timsutton/mcxToProfile
- carlashley/meecxprofile: MCX To Profile re-imagined in Python 3
Notarized Package Installer
- Notarization for MacAdmins – Scripting OS X
- The Encylopaedia of Packages, MacDevOps YVR ’21 – Scripting OS X
- Notarizing macOS Software Before Distribution – Developer Documentation
- Notarize a Command Line Tool with notarytool – Scripting OS X
- WWDC 21: “Faster and Simpler notarization for Mac apps“
- Customizing the Notarization Workflow – Developer Documentation
Conclusion
- Resource Files (GitHub Gist
- scriptingosx/MSA-Demo-Chooser (completed project)
Things you could add:
Command Line Tool
- extend the command line tool’s help text
- add an
--identifier
option to thelist
anddefault
sub-commands that returns the apps’ identifiers rather than the paths - add support for file type handlers
SwiftUI Application
- Multi-line icon grid, or at least a scrollable icon list
- multiple schemes (http, mailto, ssh) with tabs
- proper window size management
- Exclude apps by identifier (list provided by defaults/config profile)
- add support for file type handlers
- add more 🍌
Tutorials
- Use Swift Package Manager and Swift’s ArgumentParser to build a Command Line Tool – Scripting OS X
- Introducing Swift UI – Apple SwiftUI Tutorials
- Build a macOS Application to Run a Shell Command with Xcode and SwiftUI – Scripting OS X
- Scripting with SwiftUI (I) – Coding a color picker View – Woody’s findings
- Scripting with SwiftUI (II) – Scripts Provider – Woody’s findings
- Scripting with SwiftUI (III) – Forms – Woody’s findings