Skip to content

feat: Icon generation fix - #9

Open
DanielCech wants to merge 4 commits into
masterfrom
dc/fix/icon-generation-fix
Open

feat: Icon generation fix#9
DanielCech wants to merge 4 commits into
masterfrom
dc/fix/icon-generation-fix

Conversation

@DanielCech

@DanielCech DanielCech commented Aug 6, 2026

Copy link
Copy Markdown
Member

Why

Previously, VersionIcon wrote generated icons straight into the tracked --appIcon asset catalog. Every configuration switch (e.g. Debug ↔ Release) re-wrote those files, leaving the source assets "dirty" after almost any build and polluting git diffs.

What changed

  • Added an opt-in --outputAssetCatalog <path> option. When set, VersionIcon generates the app icon set into a separate, build-only .xcassets catalog instead of touching the source AppIconOriginal-derived assets.
  • The generated catalog and Contents.json are created/synced automatically from AppIconOriginal on demand.
  • Existing setups that don't pass the new flag keep the previous (unchanged) behavior — fully backwards compatible.
  • Documented the new setup in the README (build phase order, Copy Bundle Resources, Primary App Icon Set Name, ignoring the generated catalog in source control).
  • Added regression tests covering multiple generated configurations to confirm source icons stay untouched.
  • Updated the distributed Bin/VersionIcon binary.

Result

Projects that adopt --outputAssetCatalog no longer see their tracked icon assets modified/marked dirty on every configuration build.

I am testing it on Memoaire project:

image

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an opt-in “generated asset catalog” mode so VersionIcon can write configuration-specific app icons into a separate .xcassets output directory, avoiding modifications to tracked source icon assets.

Changes:

  • Added --outputAssetCatalog <path> CLI option and threaded it through ScriptSetup.
  • Updated app icon folder resolution to support generating/syncing an output .appiconset based on AppIconOriginal.
  • Added a regression test validating source icons remain untouched when generating multiple configurations; documented usage in the README.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Tests/VersionIconTests/VersionIconTests.swift Adds regression coverage for generated-catalog mode ensuring source icons stay unchanged across multiple runs/configs.
Sources/VersionIcon/Support/Models.swift Extends ScriptSetup to carry the optional generated asset catalog output path.
Sources/VersionIcon/Support/AppSetup.swift Implements output catalog mode by preparing/syncing a generated .appiconset and using it as the destination folder.
Sources/VersionIcon/main.swift Exposes --outputAssetCatalog CLI option and passes it into ScriptSetup.
README.md Documents the new generated asset catalog workflow and the new CLI parameter.
pr_description.md Adds PR summary notes (currently includes a screenshot placeholder).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Sources/VersionIcon/Support/AppSetup.swift
Comment thread pr_description.md Outdated
…atalog

Previously the guard only rejected an output path resolving to the exact
same appiconset folder as appIconOriginal, so pointing --outputAssetCatalog
at the same tracked .xcassets catalog (under a different appiconset name)
would still dirty tracked assets. Also drops the leftover screenshot TODO
from pr_description.md.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

@ipek ipek left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little confused, you're adding the option to use xcassets but guard against the option to use AppIcon assets, why? Does dev need to create and maintain separate assets catalog just for generated app icons? How about it just defaults or guides dev to usual app assets? Let's discuss before merging.

Comment thread pr_description.md Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this file.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done — removed pr_description.md in 87a713e. It was PR-only metadata and is no longer part of the repository.

Comment thread README.md Outdated
By default, VersionIcon keeps the historical behavior and writes generated images into the `--appIcon` asset. For new projects, use `--outputAssetCatalog` to keep source assets immutable:

```shell
"Pods/VersionIcon/Bin/VersionIcon" \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this Pods path correct? We should be dropping CocoaPods in favour of SPM.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the new generated-catalog example in 87a713e to use the SPM-neutral VERSION_ICON_BIN and VERSION_ICON_RESOURCES variables. The README now explains that the executable can be built with Swift Package Manager and that the resources live in the package's Bin directory. The repository still contains the legacy CocoaPods installation documentation and podspec for existing users; removing that distribution path is a separate migration decision.

Summary:
- Normalize repeated value-bearing command-line flags so the last value wins.
- Add regression coverage and rebuild the distributed executable.
- Clarify generated asset catalog ownership and use an SPM-neutral README example.
- Remove the PR-only description file.

Rationale:
- The PR branch referenced a missing helper and could not build.
- The generated catalog is separate output, while AppIconOriginal remains the source asset.

Tests:
- swift test
- swift build -c release
- swiftformat changed Swift files --lint
- git diff --check

SwiftLint remains blocked by pre-existing repository violations.
@DanielCech

Copy link
Copy Markdown
Member Author

@ipek Thanks for raising this. The guard is not against using normal AppIcon assets; it prevents --outputAssetCatalog from pointing into the same source .xcassets catalog as AppIconOriginal. VersionIcon still reads AppIconOriginal from the project's usual asset catalog, while it creates and maintains the generated catalog and app-icon sets itself. Developers only need the one-time Xcode wiring to include that output and select the generated app-icon set; the generated files do not need manual maintenance. I kept the option opt-in because existing projects retain their current behavior without it. The README now makes this source/output distinction explicit. Generating into DerivedData by default would be a broader Xcode integration change, so I left that for a separate discussion.

@DanielCech
DanielCech requested a review from ipek September 1, 2026 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants