Skip to content

feat: add On-Demand Resources (ODR) tag support - #379

Open
kramnadroj wants to merge 1 commit into
kronenthaler:masterfrom
kramnadroj:feat/odr-asset-tags
Open

feat: add On-Demand Resources (ODR) tag support#379
kramnadroj wants to merge 1 commit into
kronenthaler:masterfrom
kramnadroj:feat/odr-asset-tags

Conversation

@kramnadroj

Copy link
Copy Markdown

Problem

There was no programmatic way to assign On-Demand Resource tags to files in an Xcode project using mod-pbxproj. Users were forced to either mutate .pbxproj files directly via shell scripts, or use PBXGenericObject parsing as an undocumented workaround. This was raised in issue #298.

ODR requires two distinct mutations to the project file:

  1. Setting ASSET_TAGS in the settings of a PBXBuildFile entry to associate a file with specific tags
  2. Registering those same tags in KnownAssetTags under attributes in the PBXProject section

Neither was supported.

Solution

PBXBuildFile — new methods following the same pattern as ATTRIBUTES:

  • get_asset_tags() — returns the current ASSET_TAGS list for a build file
  • add_asset_tags(tags) — adds one or more tags (string or list)
  • remove_asset_tags(tags) — removes tags and cleans up empty settings
  • create() now accepts asset_tags=None

PBXProject — new methods for managing the project-level tag registry:

  • add_known_asset_tags(tags) — adds tags to attributes.KnownAssetTags (no duplicates)
  • remove_known_asset_tags(tags) — removes tags and cleans up empty attributes

FileOptions — new asset_tags=None parameter for the high-level API. When add_file() is called with asset tags, the library automatically updates both the build file's ASSET_TAGS and the project's KnownAssetTags in one step.

Usage

project.add_file("resources/level1.dataset",
                 file_options=FileOptions(asset_tags=['level1', 'bonus-content']))

This produces the correct structure in the .pbxproj:

// PBXBuildFile section
AB1234 /* level1.dataset in Resources */ = {
    isa = PBXBuildFile;
    fileRef = AB5678 /* level1.dataset */;
    settings = {ASSET_TAGS = (level1, "bonus-content", ); };
};

// PBXProject section
attributes = {
    KnownAssetTags = (level1, "bonus-content", );
};

Tests

  • TestPBXBuildFile — 10 new tests covering get_asset_tags, add_asset_tags, remove_asset_tags, creation with tags, and cleanup of empty settings
  • TestPBXProject — 7 new tests covering add_known_asset_tags, remove_known_asset_tags, duplicate prevention, and cleanup of empty attributes
  • TestProjectFiles — 3 new integration tests verifying that FileOptions(asset_tags=...) correctly sets ASSET_TAGS on build files and registers tags in KnownAssetTags, and that files added without tags are unaffected

Closes #298

Add programmatic support for managing On-Demand Resource tags, resolving
the missing feature raised in issue kronenthaler#298.

- PBXBuildFile: add get_asset_tags(), add_asset_tags(), remove_asset_tags()
  and asset_tags parameter to create(), following the same pattern as ATTRIBUTES
- PBXProject: add add_known_asset_tags() and remove_known_asset_tags() to
  manage the KnownAssetTags registry in project attributes
- FileOptions: add asset_tags parameter so add_file() automatically sets
  ASSET_TAGS on the build file and registers tags in KnownAssetTags

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

Copy link
Copy Markdown
Author

Committer here. Not a dev. A QA that found your tool super useful for this use case. Tasked claude with adding it for others. Unsure if you have any AI rules in the repo

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.

[FEAT] Add support for Creating/Deleting On Demand Resource Tags

1 participant