As mentioned above, I created a Python script for analyzing the iMazing App Library and purge icons. Version 1.1 of the script may be copied from here.
Soon to be Frequently Asked Questions:
Q: What is the iMazing App Library?
A: iMazing is a product for interfacing with iDevices. One of its features is app management, where you can do the kinds of things you used to be able to do in iTunes. Such as, download the .ipa files for apps and install them.
The iMazing App Library is like the iTunes App Library of downloaded apps, plus it shows apps that you can download because they were previously purchased. That is, they’re in your App Store account.
Q. Where does iMazing store the App Library?
A. The default location is ~/Library/Application Support/iMazing/Library
, but the user may have set iMazing to use a different location. The script will use whatever location is the current setting in iMazing.
Q. What’s in the App Library?
A. At the root is a file Apps.plist, which is the database that tracks all of the apps in the library.
There’s an Apps subfolder that contains all the downloaded .ipa files. Under this folder is an Icons folder with thousands of icon files.
Q: Why create this script?
A: Two reasons. The first is that sometimes the downloaded .ipa files get out of synch with what iMazing thinks it has downloaded. (This used to happen quite often, but now it happens rarely). When this happens, it is very difficult to figure out which .ipa files are the orphans, because the .ipa file name can be wildly different than the app name.
The second reason is purging of the Icons folder. iMazing stores one or two icon files for every version of every app that was downloaded or is (or was!) in your App Store account. It doesn’t appear that it ever removes these icon files, even when the app version they are for is long gone.
Q: How does the script work?
A: The script matches up the .ipa files to their associated entries in the Apps.plist, and then displays the app name, version, and .ipa file.
It will tell you if the number of .ipa files doesn’t match the Library, and tell you which .ipa files are orphans.
For purging of icons, it keeps the icons for any downloaded .ipa files, and the icons for the most recent version in the App Store.
It will not run the icon purge if there’s a mismatch between the number of .ipa files and the number of downloads registered in the Apps.plist. You must resolve the discrepancy first.
Q: What version of Python does this require?
A: I tested it with Python 3.9.6, which is the Python that comes with macOS Ventura. It will probably work with newer Python versions, and maybe some older ones.
Q: What if I don’t want to purge icons?
A: Comment out the last line in the script?
Q: What? Why isn’t that a parm to the script?
A: I developed it using Visual Studio Code, where it is harder to pass in parms, and I was too lazy to add the parm parsing code. (There’s a neat way to do this in Python, though!)
Q: How do I run it?
A: Open a terminal window, enter python3 path to script
Q: What is the recommended steps for running it, with icon purging?
A: I’d advise:
- Open iMazing and inspect the App Library. Check if any apps are missing their icon; if so then it won’t be my fault that the icon is still gone after the purge!
- Close iMazing
- Duplicate the Icons folder just in case
- Run the script
- Open iMazing and re-check the icons. Are any missing now, that weren’t before? That would be a bug.
- If everything’s fine then you can delete the Icons folder backup.
Q: When I got to step 5, it immediately downloaded more icons. Doesn’t that mean the purge was too aggressive?
A. It appears that iMazing downloads icons for every app version that it knows about (i.e. are registered in the Apps.plist), even if that version isn’t downloaded nor could it be from the App Store. So it may download a couple hundred icons that were just purged. But it still will be thousands less than it had before.
On my machine, I had 17,538 icon files. The script purged 16,925, keeping 613. Opening iMazing downloaded 223, so the final total was 836.
Q: Is there a bug bounty?
A: Yes. I will award 836 free Internet points for each bug.
Q: Are you a Python programmer? This script seems {impressive or poorly coded}.
A: Not in my real job, except for very recently. For personal use, I started coding Advent of Code in Python in 2021; previously I was using REXX.
Q: Did you use AI to code it?
A: I am using Google Gemini Code Assist for code completion; the free GitHub Copilot has a small number of completions per month. But it didn’t write the code for me.