Swifties in the Wild: A Tour of My Swift Projects
If you aren’t aware I’ve been building little apps in Swift for the last few years, and two pieces of advice have always stuck with me:
- Good sys admins build the tools they want.
- Take something you’ve already done and do it all over again in a different language.
With those two principles in mind, here are the tools I’ve written in Swift:
SC Menu
SC Menu is a simple menu bar App that lets you view the certificates on your smart card. This feature worked through macOS 10.14 (Mojave) within Keychain Access but no longer existed when Apple fully switched from TokenD to CrytpoTokenKit in macOS 10.15 (Catalina). SC Menu also allows you to inspect some of the embedded card data, export certificates and collect debug information.
Air Drop Assistant
Air Drop Assistant (ADA) is another menu bar app. It gives you more control over your AirDrop settings than normally available on macOS. On iOS, when you switch AirDrop to “Everyone”, after 10 minutes it automatically switches back to “Contacts Only”. ADA brings that feature to macOS and more; it allows you to choose between “Contacts Only” and “Off” as well as set the time it’s allowed. You can also restrict transfers to incoming only or outgoing only. And all manageable with configuration profiles pushed via MDM.
Swefaults
Swefaults allows you to easily view the real value of what settings are through the system. Using a command like defaults read com.apple.example
will read that domain from only the user level. Reading the plist file directly reads what’s written on disk at that file. But since there are a handful of places that preferences can be stored, Swefaults displays what’s actually loaded in memory and tries to show where it’s set /System/Library/Preferences
,/Library/Preferences
,/Library/Managed Preferences
,/Users/USERNAME/Library/Preferences
,/Users/USERNAME/Containers/.../Data/Library/Preferences
controlfreak_lookup
This was my first attempt at a cross platform binary. This will compile and run on macOS, Windows, and Linux (with the right libraries and DLLs). This command line app is quick way to query https://controlfreak.risk-redux.io/ for NIST 800–53 control information.
jamf-smartcard-tool-CLI
My second attempt at cross platform development. This is another command line app. This one interacts with the Jamf Pro API, grabbing information and using the API to update some attributes. This one actually grabs information from the Windows registry for configuration settings of the binary.
Smartcard Enforcement Utility
This one is not open source and was built as an internal tool. This is the GUI version of the tool above. It interacts with the Jamf Pro API to get data and update specific attributes. The original version of this was written in January 2019 as my first attempt at a Swift GUI app. I just recently rewrote it in SwiftUI, which only took 3 days for basic function, then another week or more of polishing it up.
Loaner Laptop Check-Out (macOS)
This is another macOS app that allows you to interact with the Jamf Pro API. This was built because the school I once worked at had loaner laptops, so this was a way to track them using Jamf instead of a pen and paper.
Loaner Laptop Check-Out (iOS & Catalyst)
My only attempt at an iOS app. This works on iOS and as a Catalyst app on macOS. I never published it on the App store and it had to be side loaded.
mSCP GUI Front End
A proof-of-concept GUI for the macOS Security Compliance Project. It uses a privileged helper to run checks and fixes directly from the YAML files (no generated scripts) and can even generate a compliance PDF. Note: This was built before the introduction of ODVs in the project — do not use for production.
I used to hate programming — I really struggled with it — until I found the right projects to dive into. If you’re learning to code, you’re not alone: it’s tough, but stick with it and pick projects that excite you.
I never set out to be a developer, in fact the many times I tried to sit down and really learn how to use a compiled language I failed over and over and over and over and over again…dating back as far as the 90s with C, and C++ in high school and then later in college and post college adult life trying to learn Swift. But something changed around 2016 that helped me a ton.
In 2016 at the Jamf User Nation Conference, there was a presentation by Joel Rennich title “Swift, JSS API and You!
https://www.youtube.com/watch?v=eRaApiqZkvI
After this presentation, I asked Joel for some help on getting started, and it’s stuck with me ever since. He said “Take something you’ve already done, and do it again”.
I found the eBook Hacking with Swift (https://www.hackingwithswift.com/) in 2018 and went through Hacking with macOS since I was mainly interested in Swift on macOS…this book was AWESOME, I was able to follow it, and I still go back and to see how to do certain things. I also found that my local community college actually had an Intro to Swift Programming. This was a little bit too easy as it was more like an Intro to Programming, explaining what a variable is and concepts like that…but every little bit helps. And now Apple has tutorials on things like SwiftUI which are pretty useful. https://developer.apple.com/tutorials/swiftui/
The resources are out there, just start small, and don’t get overwhelmed. If your code compiles and does what you want, it’s good enough! Progress over perfection.
These views are my own and not the views of my employer. If you have any questions or want more information on this, feel free to contact me on the MacAdmins Slack(boberito), Linkedin(linkedin.com/in/bob-gendler-8702014), GitHub(http://github.com/boberito/) or email(bobgendler@gmail.com).