Swift UI Tutorial – Part 3

The big conferences expect you to provide a topic and a brief description several months in advance. This can be challenging as you have to pick something that you think will still be interesting in eight months or so, even if there is a WWDC and the larger part of the beta phase of a new macOS and iOS version in between. It also has to be able to hold my attention for about eight months, which is not an easy requirement.

I usually try to meet that challenge by choosing something that is complex enough that it has a large likelihood of remaining relevant. For this year’s JNUC, I chose “Use Swift with the Jamf API.” This would very certainly remain relevant, as both Swift and the Jamf Pro API were certain to remain in existence. I was also not expecting too great changes in either and if there were smaller changes—both Swift and the Jamf API update regularly—I was confident I would be able to handle them.

It also covered another goal I have for my presentation: it was something I didn’t really know at the time and wanted to learn more about. I had dabbled with SwiftUI before, most prominently for my 2021 MacSysAdmin Online presentation “Let’s Swift Again” and I had also tried myself with using the Jamf API from Swift. But the new concurrency features of Swift 5.5 looked like they could make the code much more interesting.

My hunch was correct. But, even though the new concurrency features simplified the code, using Swift to retrieve and work with objects from the Jamf API still remained quite a bit more complex than doing so with curl in a shell script. A JNUC session was supposed to fit into 30 minutes.

So, I hatched a crazy plan. To remain in the 30 minutes, I would just superficially introduce the most important concepts in the sessions, and then publish a tutorial and some sample code that would explain the details. Ideally, the tutorial would publish around the same time as JNUC.

Even early in putting together the session slides and sample code, I realized, there is far too much to explain for a single post. So it would become a series of posts. No problem, I have done that before. I suggested the series to Jamf marketing and they were happy to go with it, so I was committed.

I did manage to get the first part done and published in time for JNUC. Then the work that piled up over being away for the conference struck and it took a while to get part two out. Part three was published yesterday. The project is starting to take form and is diving into some really essential, but also exciting features of Swift.

I am polishing part 4 right now and will send it to the great people who run the Jamf blog for editing and more polishing soon-ish. I am working on the sequels, where we finally, actually will get into the SwiftUI part of the tutorial. I expect there to be seven parts in total, though this project may have more surprises for me yet.

I think this worked out well, even though it certainly turned out to be far more complex and far more work than I had originally anticipated. I have certainly learned a lot along the way, so that goal was achieved! I hope you will enjoy this series as much as I did writing it. (Some people like it.)

Next year, maybe I will go for something less complex… maybe…

Weekly News Summary for Admins — 2022-11-18

Even with… what ever it is that is happening at Twitter… serving as a constant distraction, there were a lot of other interesting posts and articles this week. Put together for you to catch up and ignore the impending doom of our favorite bird site for a while…


(Sponsor: Mosyle)

Mosyle Logo

The only Apple Unified Platform for Business

Mosyle is the only solution that fully integrates Enhanced MDM, Endpoint Security, Internet Privacy & Security, Single Sign-On, and Application Management on a single Apple-only platform.

Click here to learn why Mosyle is all you need to work with Apple.


If you think your company or product is a good fit to sponsor this newsletter, please contact me!

If you would rather get the weekly newsletter by email, you can subscribe to the Scripting OS X Weekly Newsletter here!! (Same content, delivered to your Inbox once a week.)

News and Opinion

Twitter

macOS Ventura and iOS 16

macOS and iOS Updates

Social Media

  • Harald Monihart on LnkedIn: macOS Ventura is still a certified UNIX operating system. It’s hardly mentioned in Apple‘s marketing these days, every macOS release still undergoes the UNIX certification process by The Open Group
  • Aaron Zollo on Twitter: “After you install the new Security Response on iOS 16.2 Beta 3, you can see a separate build number and you have the option to uninstall it.”
  • Justin Velgos on Mastodon.design: “Made an iOS Shortcut to let you follow someone from a different Mastodon instance without the copy/paste hoop-jumping.” (thread)

Security and Privacy

Support and HowTos

Scripting and Automation

Updates and Releases

To Listen

Just for Fun

Support

If you are enjoying what you are reading here, please spread the word and recommend it to another Mac Admin!

If you want to support me and this website even further, then consider buying one (or all) of my books. It’s like a subscription fee, but you also get a useful book or two extra!

Installomator v10.0

After three betas and a lot of testing, we have (finally) released Installomator v10.

If you haven’t been following the betas, then you should really read the release notes, as well as those of the previous betas.

Major new feature is integration with Bart Reardon’s excellent Swift Dialog. Installomator can now send download and install progress to be displayed with Swift Dialog. There are several examples made by Soren Theilgaard and myself in the repo.

This update brings Installomator to more than 500 applications. And there are several more queued up in pull requests that we need to test and merge. The feedback from the community has been amazing. Many thanks to everyone who contributed and helped!

Also, many thanks to Søren, Adam, and Isaac, who are co-managing the project with me, I couldn’t do it without them!

On viewing man pages (Ventura update)

I have written about man pages before. That post references an even older post, which is actually the second oldest post on this blog. Most of the recommendations in the posts still hold true, but there is one change relevant to macOS Ventura and one other thing that is worth adding.

Ventura’s Preview app lost the ability to render postscript or ps files. This breaks the previous, popular shell alias to open a man page in Preview. However, the amazing community in the #scripting channel of the MacAdmins Slack have figured out a replacement. They have asked me to share it.

Add this function to your shell configuration file: (bashzsh

preman() {
    mandoc -T pdf "$(/usr/bin/man -w $@)" | open -fa Preview
}

Then you can run preman <command> in Terminal and the man page will render beautifully in Preview. If you want to override the man command to actually use this function instead of the built-in command, add this alias:

alias man preman

If you then need to revert to the actual man command for a test of something, just add \ before the command: \man <command>

Update: Pico has expanded this into a full blown script which caches the pdfs.

Myself, I had not noticed this change, because I prefer opening the ‘yellow’ man pages in Terminal app. You can do so by entering a command in the Help menu, or by using the x-man-page URL scheme. In these yellow terminal windows, you can scroll and search in the text with command-F. You can also do a secondary click (right/ctrl/two-finger click) on any word and it will offer to open that man page in the context menu.

If the yellow man page windows annoy you, you can change their appearance by modifying Terminal’s “Man Page” profile. I modify it to use my favorite mono spaced font at a larger size. I like the yellow background because it stands out.

In the previous posts, I had a simple function you could add to your shell configuration files, but I have since refined this to also support man page sections (the number you sometimes see after a command, you can learn what they mean in the man page for the man command).

xmanpage() {
  if [[ -z $2 ]]; then
    open x-man-page://"$1"
  else
    open x-man-page://"$1"/"$2"
  fi
}

With this, you can open the desired section in the ‘yellow’ man window with xman 2 stat. This works already with the preman function. The mandoc command knows how to deal with the extra argument, the URL scheme needs a bit of extra work.

If you want to override the normal man command you can, again, use an alias in your shell configuration file:

alias man xmanpage

This way, I can have both functions in the configuration file and choose or change which function (if any) overrides the normal man by just changing the alias.

When you work in Terminal for a while you may accumulate a lot of yellow man page windows. You can use this AppleScript/osascript one-liner to close all Terminal windows which use the ‘Man Page’ profile at once.

osascript -e 'tell application "Terminal" to close (every window where name of current settings of every tab contains "Man Page")'

And while this one-liner is succint, it is still easier to wrap this in a function for your shell configuration file:

closeman() {
  osascript -e 'tell application "Terminal" to close (every window where name of current settings of every tab contains "Man Page")'
}

If you enjoyed this excursion into macOS Terminal and command line tricks and configuration, you might like one of my books: “macOS Terminal and shell” and “Moving to zsh”.

Weekly News Summary for Admins — 2022-11-11

The first Apple Silicon Macs with the M1 chip were introduced two years ago. The MacBook Air, MacBook Pro 13″ and Mac mini all kept the same enclosure designs as their Intel-based predecessors, but the chips inside were the largest change for the Mac platform since the Intel transition in 2006.


(Sponsor: Mosyle)

Mosyle Logo

The only Apple Unified Platform for Business

Mosyle is the only solution that fully integrates Enhanced MDM, Endpoint Security, Internet Privacy & Security, Single Sign-On, and Application Management on a single Apple-only platform.

Click here to learn why Mosyle is all you need to work with Apple.


If you think your company or product is a good fit to sponsor this newsletter, please contact me!

At the JNUC conference earlier this year, I noticed that there were no chains of powerstrips running through the audience areas of the presentation rooms. You couldn’t charge your laptop or tablet in the sessions and nobody seemed to be bothered by this. Just this week I ran my MacBook Air M2 and my iPad Air on battery for two days before I bothered looking for my power supply. I still had enough power to run them for the rest of day, which was a good thing, since I realized I still had the US power plug from aforementioned trip to JNUC on my power supply.

Even though they seem to merely sip power, the new chips aren’t slouches either. Apple has had an exceptional position in power/performance ratio in the phone and tablet space, and now, unsurprisingly, Apple laptops are in this position, as well.

For desktop computers, where power use is not quite such a priority, the M1 Max and Ultra configurations provide astounding capability. The only Mac line that has not yet transitioned to Apple Silicon is the Mac Pro. Given the connectivity and expandability of the Mac Pro, it is not suprising this is the last model to transition. The Mac Studio hints at what might be possible, but we will have to wait and see. I could be ungenerous and point out that Apple missed their self-imposed two-year time line of transistioning to Apple Silicon, but honestly, with all the supply chain challenges and other world events that happened since then, it is an amazing achievement to be where they are now.

Apple Silicon is one of the reasons Apple has been the only computer vendor to show growth in the last quarter.

Another amazing aspect of the transition is how smooth it was on the software side. macOS ran without issues from the days of the Developer Kit. This was Apple’s third processor transition in as many decades and you could tell. Rosetta on Apple silicon provides amazing performance for the software that hasn’t been compiled for Apple silicon yet and it is fairly straightforward for vendors and developers to provide native and unverisal binaries. Even though some developers, especially those building electron-based apps, still don’t seem to understand the concept of universal apps.

Apple now has reached their goal of controlling the entire package, or at least the most important parts. They design and build the hardware, the interfaces, the silicon, the software, and many of the services that connect the device to the net and to other devices.

PowerPC was the core for Macs for 12 years. Intel chips lasted for 14 years. I am looking forward to what happens in the next 12-15 years.

If you would rather get the weekly newsletter by email, you can subscribe to the Scripting OS X Weekly Newsletter here!! (Same content, delivered to your Inbox once a week.)

News and Opinion

macOS and iOS Updates

Support and HowTos

Scripting and Automation

Updates and Releases

To Watch

To Listen

Support

If you are enjoying what you are reading here, please spread the word and recommend it to another Mac Admin!

If you want to support me and this website even further, then consider buying one (or all) of my books. It’s like a subscription fee, but you also get a useful book or two extra!

Weekly News Summary for Admins — 2022-11-04

Ventura is still the dominating topic in the week after its release. We got more articles from admins on managing the new macOS, but also a few issues are surfacing.


(Sponsor: Mosyle)

Mosyle Logo

The only Apple Unified Platform for Business

Mosyle is the only solution that fully integrates Enhanced MDM, Endpoint Security, Internet Privacy & Security, Single Sign-On, and Application Management on a single Apple-only platform.

Click here to learn why Mosyle is all you need to work with Apple.


If you think your company or product is a good fit to sponsor this newsletter, please contact me!

The other dominating topic in tech this week was the Twitter takeover and how or whether the platform will survive and whether users should hold out or not. I am fairly active on Twitter with my @scriptingosx account and to a lesser degree with my personal @titanonearth account, which is nearly 16 years old. Twitter is a main driver of traffic to my weblog, so I have no plans as of yet to leave the platform. But, I will watch and it is likely I will reduce my engagement, possibly to the point where there will only be links to blogposts.

If you are planning to reduce your activity or want to remove yourself completely from Twitter and other social media, you can follow my blog. It has an RSS feed and I strongly recommend using an RSS reader app as an alternative to getting your news addiction satisfied. My favorite is NetNewsWire.

You can also subscribe to the weekly news summary by email. (Or recommend it someone else who wants to reduce their engagement on Twitter or social media.)

And last but not least, there is @scriptingosx@mastodon.social. I’ve had that account for a while already and I can tell that traffic and engagement there has picked up significantly in the last week.

macOS Ventura and iOS 16

Social Media

  • Daniel Jalkut: “In light of everything happening at Twitter, a lot of people are wondering “where to go next”. May I suggest, and I am speaking to myself here too, that you invest in your own blog on your own domain? Own your own content, and share your thoughts independently of dingaling CEOs.”
  • Mr. Macintosh: “MacAdmins asked & Apple listened. The macOS Monterey 12.6.1 M1 IPSW restore file is now available. This is important for 2 reasons: 1) After 11.6/12.6 Apple usually stops creating IPSW’s. 2) Admins can restore M1’s & Ventura can be blocked without updating”

Security and Privacy

Support and HowTos

Scripting and Automation

Updates and Releases

To Watch

To Listen

Just for Fun

Support

If you are enjoying what you are reading here, please spread the word and recommend it to another Mac Admin!

If you want to support me and this website even further, then consider buying one (or all) of my books. It’s like a subscription fee, but you also get a useful book or two extra!

Some Swift Updates

Earlier this year, at JNUC I did a presentation on how to “Use Swift with the Jamf API” and one of the things promised there is a series of articles that described more details than I could cover in the 30 minute presentation.

Note: the session video (and all other JUNC sessions recordings) is available to attendees of JNUC in the conference portal for 60 days. Then the sessions will be made available on YouTube for everyone.

The first part has been out for a while. But for various reasons, the second part took much longer than anticipated. Nevertheless, the wait is over and you can go read the second part here!

Future installments will hopefully not take as long.

If you worked your way through the first part, the Jamf Blog CMS had initially mangled some of the Swift code which lead to some errors. Those errors are now fixed. The sample code repo always had the correct code.

Much earlier (last year) I did a different presentation on Swift at MacSysAdmin. Some of the code used in that presentation’s demo to change the default browser was already deprecated. I still used the deprecated LaunchServices functions because the replacement functions were only made available in Monterey and I wanted the code to work on older versions of macOS, as well. Now, in Ventura, the deprecated functions have been removed. I have updated the sample code to now check the macOS version and use the older LaunchServices functionality on Big Sur and older, and the new NSWorkspace based functions in Monterey and higher. You can get the sample code in this gist.

I enjoyed putting together these presentations and tutorials.

Weekly News Summary for Admins — 2022-10-28

Release week! If this were a printed newsletter, it would be quite heavy: lots of links and posts, both from Apple and the MacAdmin community.


(Sponsor: Mosyle)

Mosyle Logo

The only Apple Unified Platform for Business

Mosyle is the only solution that fully integrates Enhanced MDM, Endpoint Security, Internet Privacy & Security, Single Sign-On, and Application Management on a single Apple-only platform.

Click here to learn why Mosyle is all you need to work with Apple.


If you think your company or product is a good fit to sponsor this newsletter, please contact me!

I think it is fair to say that the Ventura beta and release has some challenges for system administrators. On the other hand, the updated Apple Platform Deployment guide and several support articles were ready on day one with lots of great information.

Many MacAdmins were awaiting the release and the end of the NDA and ready with several posts on topics they learned about during the beta. The most posts were on the new “Login and Background Items management” but several other posts on other new features and issues, as well. As always, thanks to everyone who shares their knowledge!

Aside from the major releases for macOS Ventura 13.0 and iPadOS 16.1, we also got iOS 16.1, watchOS 9.1, updates for tvOS, HomePod, the apps formerly known as iWork (Numbers, Keynote, and Pages), a new Xcode 14.1 RC, updates for Apple Business Essentials, Safari, macOS Monterey 12.6.1, Big Sur 11.7.1, and iPadOS and iOS 15.7.1. Also, the next round of updates for all the platforms is available in beta on AppleSeed for IT and for Developers, and we got a beta for the iCloud web interface.

Much to catch up on. I hope this collection of links and posts will help.

If you would rather get the weekly newsletter by email, you can subscribe to the Scripting OS X Weekly Newsletter here!! (Same content, delivered to your Inbox once a week.)

News and Opinion

macOS Ventura and iOS 16

macOS Ventura 13.0

iPadOS and iOS 16.1

watchOS 9.1

tvOS 16.1

HomePod Software

Services

Applications

User Guides

Apple Support

Reviews

Reactions and Posts

Login Items in Ventura

macOS and iOS Updates

Social Media

  • Mischa vd Bent: “Did you know about this nice feature with GitHub? Visual Studio Code is build into their website.”
  • John C. Welch: “One nice thing about MS (unlike Apple) having such detailed documentation about the powershell/VBA scripting implementation for Office, is that same model is the source for the AppleScript implementation, so you can use the PS/VBA docs to help you with AppleScript.”
  • Rosyna Keller: “In tons of places in macOS, including in Xcode’s log when notarization fails, there’s typically a “?” button in dialogs that if you click it, will bring you either to local or online documentation. In the notarization case, these buttons will take you to specific online docs.”

Security and Privacy

Support and HowTos

Scripting and Automation

Updates and Releases

To Listen

Support

If you are enjoying what you are reading here, please spread the word and recommend it to another Mac Admin!

If you want to support me and this website even further, then consider buying one (or all) of my books. It’s like a subscription fee, but you also get a useful book or two extra!

Weekly News Summary for Admins — 2022-10-21

This is the “Ventura-Eve” edition. On Tuesday, Apple release, a new iPad (no moniker), iPads Pro with M2 chips, AppleTVs and announced the release dates for macOS Ventura and iPadOS 16.1: 24 October. Do you feel ready!?


(Sponsor: Mosyle)

Mosyle Logo

The only Apple Unified Platform for Business

Mosyle is the only solution that fully integrates Enhanced MDM, Endpoint Security, Internet Privacy & Security, Single Sign-On, and Application Management on a single Apple-only platform.

Click here to learn why Mosyle is all you need to work with Apple.


If you think your company or product is a good fit to sponsor this newsletter, please contact me!

While the iPad updates are appreciated, they leave the iPad product in a somewhat confused state. Certain features are only available in certain iPad models, without a discernible pattern. The AppleTV update seems solid, but note that the ethernet port is now exclusive to the higher configuration.

The announcement happened without an “Apple Event.” Also absent were any news regarding the Mac, aside from the Ventura release date. There is still time for more product releases, with or without an event this year and I will be looking forward to them.

If you would rather get the weekly newsletter by email, you can subscribe to the Scripting OS X Weekly Newsletter here!! (Same content, delivered to your Inbox once a week.)

macOS Ventura and iOS 16

Social Media

  • Felix Schwarz: “The Ventura System Settings app includes an AppleScript sdef but so far nothing indicates it’s functional. I only get errors. For my uses, most of this can be compensated by using the x-apple.systempreferences scheme, but opening Keyboard > Shortcuts that way seems impossible.”

Security and Privacy

Support and HowTos

Scripting and Automation

Updates and Releases

To Listen

Support

If you are enjoying what you are reading here, please spread the word and recommend it to another Mac Admin!

If you want to support me and this website even further, then consider buying one (or all) of my books. It’s like a subscription fee, but you also get a useful book or two extra!

Weekly News Summary for Admins — 2022-10-14

Apple’s macOS Ventura Preview page still states “Coming this October.” The rumors, past experience and practicality point to October 24 as the release date for macOS Ventura 13.0 as well as iPadOS 16.1 and the first round of updates for iOS 16, watchOS 9 and all the others.


(Sponsor: vast limits)

uberAgent Logo

uberAgent: per-application network monitoring

uberAgent is an innovative user experience monitoring product for macOS and Windows. uberAgent’s highlights include detailed information about application performance, network reliability drill-downs, application usage metering, browser performance, and web app metrics. Try for yourself and get your free 100 user community license at uberagent.com.


If you think your company or product is a good fit to sponsor this newsletter, please contact me!

On the other hand, Stage Manager still seems to be quite a mess in both iPadOS and macOS. Also, there was no announcement for an Apple Event on October 18, which you would expect if Apple wanted to announce new iPads Pro and/or a new Mac Pro to go with the iPadOS and macOS releases. Apple could very well release new hardware after the system releases, but it would be unusual.

The Mac Pro is the last Mac which has not transitioned to Apple Silicon yet and the two-year transition timeline, ,promised at WWDC 2020 with the Apple Silicon reveal expires in November, two years after the first M1 MacBooks shipped. The Mac mini, which is currently available as M1 and Intel models, also seems due for an upgrade.

We did get a new round of betas this week, which brings macOS 13 to beta 11. As a MacAdmin, you really should log in to AppleSeed for IT and read the beta notes that Apple makes available there, regarding software update deferral.

If you would rather get the weekly newsletter by email, you can subscribe to the Scripting OS X Weekly Newsletter here!! (Same content, delivered to your Inbox once a week.)

News and Opinion

macOS Ventura and iOS 16

macOS and iOS Updates

Social Media

  • William Smith: “As of Tuesday this week, version 16.66 of Microsoft Office for Mac was released and will be the last version to support macOS Catalina 10.15.”

Security and Privacy

Support and HowTos

Scripting and Automation

Updates and Releases

To Listen

Support

If you are enjoying what you are reading here, please spread the word and recommend it to another Mac Admin!

If you want to support me and this website even further, then consider buying one (or all) of my books. It’s like a subscription fee, but you also get a useful book or two extra!