Python script to analyze the iMazing library

This is off topic but…

If anyone is interested, I’ve created a Python script that analyzes the iMazing App Library:

  • Matches downloaded .ipa files to the app in the library
  • Prints a table of the app name, version, and the .ipa name. Note that in iMazing, the .ipa names are cryptic. How would you know that “com.yourcompany.TestWithCustomTabs-1.ipa” is actually AccuWeather 20.0.14?
  • Identifies orphan .ipa files, i.e. files that are not actually in the library
  • Purges the Apps/Icons folder of old, unnecessary icons. It keeps all the icons for apps in your library and in your App Store account.
2 Likes

I’d be interested. Maybe put it up on github or something?

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.[1]

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:

  1. 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!
  2. Close iMazing
  3. Duplicate the Icons folder just in case
  4. Run the script
  5. Open iMazing and re-check the icons. Are any missing now, that weren’t before? That would be a bug.
  6. 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.


  1. This is not actually an uploaded file! The entire contents of the file is compressed into the URL. Which means, you’re guaranteed that what you get hasn’t been modified. To change it would require a new URL. ↩︎

3 Likes

Once upon a time, I had a lot of fun with REXX (ARexx) specifically.

Thanks!

Thanks. I like how you encoded the script in the URL. I hadn’t known that was possible (but I hadn’t thought about it).

If I have changed the default location, do I simply substitute the path to the new Library? (In case it matters, my iMazing Library is on a removable disk.)

Yes. Current script has it coded in two places, so you’ll have to change both. What I should have done is set a variable to the iMazing/Library folder, then used that to derive the location of the plist and Apps subfolders.

Maybe I can figure out how iMazing finds the Library when it is not in the default place, then it would work automatically.

Update: I changed the download URL to be for version 1.1 of the script, which now finds the current iMazing library automatically.

1 Like

It is Topaz’s Paste: a “no-database, client-side paste service. It turns text into LZMA-compressed, Base64-encoded URLs”.

This service is used by Advent of Code for users posting their solutions to Reddit. Topaz is the mastermind behind AoC.

1 Like

Didn’t the iMazing developer comment here a year or so ago when there was a thread about their new licensing model?

Hmm. I have an “Apps” folder, an “iMazing.Apps” folder, and an “iMazing Versions/Apps” folder. Each of them has many .ipa files.

You mention “Apps subfolders” (plural); are you referring to all these, but with only the Apps folder coded in the script?

I was referring to the Apps folder under the Library folder. On my machine it is at ~/Library/Application Support/iMazing/Library/Apps. This is the folder which, on my machine, contains all of the downloaded .ipa files.

I’m wondering how you have more than one folder with .ipa files, and which one is actually in use. And does each have an Apps.plist file in the parent folder?

I have…

iMazing (folder)
   Library (folder)
      Apps.plist
      Apps (folder)
          lots of .ipa files
          Icons (folder)
              lots of .png files

For what it’s worth, I started with iMazing 2, which created that folder structure. I upgraded to iMazing 3, and it kept exactly the same files. I never attempted to use both versions simultaneously.

Update: I think iMazing may only have one library at a time, which for iMazing 3 is set in iMazing > Preferences > Library > Default library location.

I changed the script so it finds that setting and uses it. So, if I have this right, wherever the user’s current Library is, that’s what will be analyzed.

Yes, I was referring to the Library folder, which for me is on an external SSD. The iMazing Library folder (including subfolders) contains downloaded .ipa files.

I, too, wonder about the multiple folders. Until you started this thread, I hadn’t paid attention to what was in the iMazing Library. Here it is.


You can see there is only one Apps.plist file (plus a backup). However, the folders iMazing.Apps and iMazing.Versions/Apps were last modified last July, and the Apps folder was modified a few days ago, which I think answers the question of which one is in use. I wonder what would happen if I moved all the .ipa files into the Apps folder.

Sweet. I’ll grab the new script. And since iMazing is currently unable to download .ipa files, I might take this opportunity to start a new Library folder.

Here’s another oddity: ‘~/Library/Application Support/iMazing/Library/Apps/Icons’ contains many .png files with a modification date that matches the Apps folder in my iMazing Library. (It does not contain nearly as many .png files as Apps/Icons in my iMazing Library, but why would iMazing be storing .png files in two different places?) One more thing. There are three .ipa files in Apps/Icons in my iMazing Library. All-in-all, it makes me think iMazing is rather sloppily programmed.

If I simply delete that Icons folder, won’t iMazing simply rebuild it?

It will try, but some of the icons may no longer be available to download.

You can make a backup of Icons and try it and see if that’s the case for you.