Glimmer / app / native / scripts / check-ios-icons.py
| 1 | #!/usr/bin/env python3 |
| 2 | """Verify both device icons in the signed IPA that will actually reach TestFlight.""" |
| 3 | import json |
| 4 | import plistlib |
| 5 | import subprocess |
| 6 | import sys |
| 7 | import tempfile |
| 8 | import zipfile |
| 9 | from pathlib import Path |
| 10 | |
| 11 | with zipfile.ZipFile(sys.argv[1]) as ipa, tempfile.TemporaryDirectory() as tmp: |
| 12 | bundle = "Payload/Glimmer.app/" |
| 13 | info = plistlib.loads(ipa.read(bundle + "Info.plist")) |
| 14 | if set(info["UIDeviceFamily"]) != {1, 2}: |
| 15 | sys.exit("The IPA must support both iPhone and iPad.") |
| 16 | for key in ("CFBundleIcons", "CFBundleIcons~ipad"): |
| 17 | primary = info[key]["CFBundlePrimaryIcon"] |
| 18 | if primary.get("CFBundleIconName") != "AppIcon" or not primary.get("CFBundleIconFiles"): |
| 19 | sys.exit(f"The {key} entry has no installed AppIcon.") |
| 20 | |
| 21 | catalog = Path(tmp) / "Assets.car" |
| 22 | catalog.write_bytes(ipa.read(bundle + "Assets.car")) |
| 23 | raw = subprocess.check_output(["xcrun", "assetutil", "--info", str(catalog)]) |
| 24 | icons = {item.get("Idiom") for item in json.loads(raw) |
| 25 | if item.get("Name") == "AppIcon" and item.get("AssetType") == "Icon Image" |
| 26 | and item.get("PixelWidth") == 1024 and item.get("PixelHeight") == 1024 |
| 27 | and item.get("Opaque") is True} |
| 28 | if not {"phone", "pad"}.issubset(icons): |
| 29 | sys.exit(f"Missing opaque 1024px AppIcon for phone or pad. Found {sorted(icons)}.") |
| 30 | print("Verified exported iPhone and iPad AppIcon artwork and Info.plist declarations.") |