"""Verify a thin ARM64 iPhone IPA, independently of the macOS build environment.""" import pathlib import plistlib import struct import sys import zipfile path = pathlib.Path(sys.argv[1]) with zipfile.ZipFile(path) as archive: assert archive.testzip() is None, "Corrupt ZIP member" prefix = "Payload/MusicBridge.app/" info = plistlib.loads(archive.read(prefix + "Info.plist")) assert info["CFBundleSupportedPlatforms"] == ["iPhoneOS"], "Not an iPhone device build" assert info["CFBundleIdentifier"] == "ru.yukinoki.musicbridge", "Unexpected bundle ID" assert info["MinimumOSVersion"] == "17.0", "Unexpected minimum iOS version" executable = info["CFBundleExecutable"] assert executable == "MusicBridge", "Unexpected executable" binary = archive.read(prefix + executable) magic, cpu = struct.unpack_from("= 8 and offset + size <= len(binary), "Invalid Mach-O load command" if command == 0x32: platforms.append(struct.unpack_from("= 8 and offset + size <= len(binary) if command == 0x32: platforms.append(struct.unpack_from("