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(binarybplist00or 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 (
0xFEEDFACF64-bit /0xCAFEBABEUniversal Fat binary) to enumeratearm64andx86_64CPU slices - The highest-resolution
AppIcon*.pngasset
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:
- Inserts a 4-byte
CgBIchunk immediately beforeIHDR. - Strips the standard 2-byte zlib header and 4-byte Adler-32 checksum from concatenated
IDATstreams (leaving raw RFC 1951 deflate blocks). - 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.