Skip icon regeneration when inputs are unchanged#8
Open
DanielCech wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
VersionIcon regenerated the app icon on every build, even when nothing changed. Because the rendering pipeline (Core Image compositing, text drawing) is not byte-deterministic, the output PNG differed slightly on each run — so git constantly showed the icons as modified, which was annoying and polluted diffs.
Solution
Each generated icon now carries a small, human-readable JSON record embedded as a standard PNG
tEXtchunk. It describes all inputs that produced the icon: version text, font, colors, position ratios, pixel size, and SHA-256 hashes of the binary inputs (original icon, ribbon, title overlay).On the next run the stored record is compared with the current inputs before rendering:
Keeping original file - no change), so git sees no modification. Rendering is skipped entirely, which also makes repeat builds faster.The chunk is an ancillary PNG chunk, so Xcode, actool, and any image viewer simply ignore it. You can inspect it with
strings Icon.png.Changes
PNGMetadata.swift— minimal, dependency-free PNGtEXtchunk reader/writerIconState.swift— theIconStateRecordinput fingerprint (uses CryptoKit, no new dependencies)IconGeneration.swift— skip-before-render check + stamping the record into the outputNote
The first run after this change regenerates all icons once (existing files have no metadata yet). After that they stay stable.