· By Alex Rivera · Release Systems

Inspecting iOS IPA Archives & Un-Crushing Apple CgBI Icons in Pure PHP

How BuildDrop parses binary Info.plists, CMS-signed mobileprovision profiles, Mach-O CPU slices, and raw deflate CgBI PNG icons without spawning macOS or Java binaries.

Traditional over-the-air distribution tools rely on macOS build servers, xcrun pngcrush, or Java apktool processes to inspect uploaded mobile binaries. Because BuildDrop is engineered to run anywhere PHP 8.2+ and MySQL run—including locked-down shared hosting with zero background daemons—every byte of binary inspection happens in pure PHP without extracting full archives to disk.

Selective ZIP stream reading

Mobile release candidates regularly exceed 500 MB to 1.2 GB due to bundled Unity scenes, ML models, and multi-architecture frameworks. Extracting an entire archive onto disk during an HTTP request wastes I/O and risks hitting execution timeouts.

Instead, BuildDrop scans the central directory of the uploaded .ipa or .apk via ZipArchive and streams only the tiny metadata entries it needs:

  • Payload/*.app/Info.plist (binary bplist00 or XML property list)
  • Payload/*.app/embedded.mobileprovision (PKCS#7 CMS wrapper around Apple's provisioning XML plist)
  • The first 4 KB of the Mach-O executable header (0xFEEDFACF 64-bit / 0xCAFEBABE Universal Fat binary) to enumerate arm64 and x86_64 CPU slices
  • The highest-resolution AppIcon*.png asset

Reversing Apple's CgBI PNG optimization in PHP

During Xcode asset compilation, Apple's actool converts standard PNG icons into a proprietary CgBI layout that web browsers refuse to render:

  1. Inserts a 4-byte CgBI chunk immediately before IHDR.
  2. Strips the standard 2-byte zlib header and 4-byte Adler-32 checksum from concatenated IDAT streams (leaving raw RFC 1951 deflate blocks).
  3. Swaps every pixel from RGBA to premultiplied BGRA byte order.

BuildDrop's CgbiPngConverter inflates the raw IDAT stream via inflate_init(ZLIB_ENCODING_RAW), reconstructs all five PNG scanline filter types (None, Sub, Up, Average, Paeth), un-premultiplies and swaps BGRA -> RGBA, and writes clean 180 px and 60 px standard PNGs—rendering crisp app icons across Safari, Chrome, and custom domain portals.