Is it possible to have a script or some sort of command-line tool that will query Apple's update servers to see what the latest version of an OS is? For example, I'd like to alert somewhere when a new iOS version is released without me having to check tech news websites or directly on my iPhone, that all seems too reactive.

Perhaps something like this already exists? Perhaps I just need to better understand how devices talk to Apple to know if they have an update available to them?

Thank you in advance for your help.

  • What would you use to script this? Apple publishes web pages on all updates, so I could see you scraping those pages or watching a Twitter feed that already scrapes the pages. – bmike Jun 3 at 15:53
  • I was thinking it might be possible to send a request to one of the update servers. Is there a Twitter account that already does this? – bmkaiser Jun 3 at 16:53
  • 2
    Yes. I like istheapplestoredown.com/ios – bmike Jun 3 at 16:55
  • 1
    @bmike Ah, nice, that one even has an API which returns JSON objects :-) – nohillside Jun 3 at 17:41

Apple has pages up beneath https://support.apple.com/en_US/downloads/ios for each major iOS release. Looking at About iOS 13 Updates one can see an overview of all available iOS13 versions.

enter image description here

In the HTML source this is coded as

<p><a href="#1341"><img alt="" src="/library/content/dam/edam/applecare/images/en_US/il/spacer.png" width="76">iOS 13.4.1<br>
<p><a href="#135"><img alt="" src="/library/content/dam/edam/applecare/images/en_US/il/spacer.png" width="76">iOS 13.5<br>
<p><a href="#1351"><img alt="" src="/library/content/dam/edam/applecare/images/en_US/il/spacer.png" width="76">iOS 13.5.1<br>

So if you are willing to adapt your script with each major release of iOS/iPadOS you could use

curl -s "https://support.apple.com/en-us/HT210393" | \
    sed -n '/\/library\/content/s|.*width="76">\([^<]*\)<.*|\1|p' | \
    tail -1

to get the most recent version available (iOS 13.5.1 right now).

  • sed -n runs sed suppressing any printing output unless specifically told so
  • /\/library\/content/ applies the following command to all lines matching /library/content
  • s|STRING-TO-MATCH|REPLACEMENT| does pattern-based string replacement
  • .*width="76">\([^<]*\)<.* takes the whole line and puts the part between width="76"> and the following < into \1
  • \1 just replaces the whole line with the content of \1 (which in this case is the version number)
  • p prints the result to stdout

This obviously matches (and prints) every line (just leave out the tail to check) so at the end we just take the last line.

What changes for sure with each major release is the URL, what might change is the code to find and extract the relevant content from the page. The sed/tail combination above works for iOS12 and iOS13 at least.

PS: You could avoid tail by running

curl -s https://support.apple.com/en-us/HT210393 | \
    sed -n '/\/library\/content/{s|.*width="76">\([^<]*\)<.*|\1|;h;}; ${g;p;}'

but this makes it hard to read for most people :-)

| improve this answer | |
  • 1
    Thank you for the reply, @nohillside ! This could very well get me what I need. Would you mind taking a moment to break down the expression used in the sed command? Not only do I want to make sure I can support this in the future on my own, but I'm curious how you were able to figure this out. – bmkaiser Jun 3 at 15:16
  • 1
    @bmkaiser see edit – nohillside Jun 3 at 15:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .