Why Xcode App Icons Break in Browsers (and How Apple CgBI Normalization Fixes It)
Inside Apple's non-standard CgBI PNG optimization inside .ipa archives and the byte-level decompression, BGRA-to-RGBA channel swap, and un-premultiplied alpha conversion required for web and OTA display.
Key Takeaway
Xcode's pngcrush optimization injects a proprietary CgBI chunk, removes zlib headers from IDAT streams, swaps RGBA to BGRA, and premultiplies alpha. Reversing those four transforms produces a standards-compliant RGBA PNG for browsers and manifest.plist.
What makes an .ipa app icon unreadable on the web
When Xcode compiles an iOS asset catalog, Apple runs iphoneos-optimize (a modified pngcrush pass) on PNG assets inside Payload/*.app/. While UIKit renders these files rapidly on iOS hardware, standard browsers, macOS Preview, Sharp, and Apple's own itunesstored display-image previews reject or corrupt colors on raw CgBI icons.
Specifically, an Apple CgBI PNG diverges from the W3C PNG specification in four structural ways.
- Prepends a proprietary 'CgBI' chunk directly before the mandatory IHDR chunk.
- Compresses pixel rows using raw deflate (inflateRaw) without the 2-byte zlib header or Adler-32 checksum.
- Stores pixel color channels in Blue-Green-Red-Alpha (BGRA) order instead of standard RGBA.
- Premultiplies R, G, and B channels against the Alpha byte.
Pure Node.js un-optimization pipeline
Instead of calling external native binaries inside request handlers, our parser worker detects the CgBI signature immediately after IHDR inspection, skips the CgBI chunk, inflates concatenated IDAT payloads via zlib.inflateRawSync, reverses PNG scanline filters (None, Sub, Up, Average, Paeth) across every row, swaps B and R channels back to RGBA while un-premultiplying alpha, re-applies standard zlib.deflateSync compression, and recomputes valid CRC32 checksums for every output chunk.
Standard non-CgBI PNGs pass through unchanged while preserving original metadata.
Frequently Asked Questions
- Do modern Asset Catalog (.car) builds still produce PNG icons?
- Yes. Xcode emits CFBundleIconFiles / AppIcon60x60@2x.png / AppIcon76x76@2x~ipad.png top-level PNGs inside the .app bundle specifically for SpringBoard and manifest previews, alongside Assets.car.
Related Guides
Ready to distribute a build?
Upload an .ipa, .apk, or .aab archive or inspect your iPhone UDID directly in Safari.