Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add On Demand Resources Support #6178

Merged
merged 7 commits into from May 6, 2024

Conversation

kapitoshka438
Copy link
Contributor

@kapitoshka438 kapitoshka438 commented Apr 11, 2024

Short description πŸ“

On-demand resources are app contents that are hosted on the App Store and are separate from the related app bundle that you download.
The resources can be of any type supported by bundles except for executable code. Supported on-demand resource types are described in Apple Developer Documentation.
Developers identify on-demand resources during development by assigning them one or more tags. A tag is a string identifier they create.

It's important for us to understand how are tags defined in generated pbxproj.

Tags assigned to resource files or folders are defined in targets PBXBuildFile section:

/* Begin PBXBuildFile section */
  ...
  6CD9B9A8A7B99902ADF2733A /* on-demand-data.txt in Resources */ = {isa = PBXBuildFile; fileRef = C76E1D013C995B4365F328A4 /* on-demand-data.txt */; settings = {ASSET_TAGS = (datafile, ); }; };
  ...
/* End PBXBuildFile section */

Tags assigned to assets in Asset Catalogs are not presented in pbxproj and defined in their Contents.json:

{
  ...
  "properties" : {
    "on-demand-resource-tags" : [
      "image"
    ]
  }
}

All tags assigned to any type of on-demand resources are listed in PBXProject section in alphabet order:

/* Begin PBXProject section */
		F6B39DFD5CF1C50192B21AD0 /* Project object */ = {
			isa = PBXProject;
			attributes = {
				BuildIndependentTargetsInParallel = YES;
				KnownAssetTags = (
					"ar-resource-group",
					"cube-texture",
					data,
				);
  ...
/* End PBXProject section */

On targets level, each tag is assigned to one of the categories below:

  • Initial install tags (alphabet order)
  • Prefetch tag order (order-sensitive)
  • Dowloaded only on demand (alphabet order)

Initial install tags and Prefetched order tags are defined in the targets XCBuildConfiguration section:

814E5CB981F34CFCEFE45501 /* Release */ = {
			isa = XCBuildConfiguration;
			buildSettings = {
				...
				ON_DEMAND_RESOURCES_INITIAL_INSTALL_TAGS = "data\\ file json";
				ON_DEMAND_RESOURCES_PREFETCH_ORDER = "image-stack image tag\\ with\\ space";
				...

The last category is default, not described in pbxproj and represents all tags from KnownAssetTags excluding tags from the first two categories.

This pull request add support for on-demand resources.

  • During project generation, we parse tags in all Contents.json in Asset Catalogs to generate KnownAssetTags (defining tags for file resources was already implemented).
  • Target init has got additional parameters to define Initial Install Tags and Prefetch Order Tags

How to test the changes locally 🧐

This PR adds new fixture: ios_app_with_on_demand_resources, with acceptance, generation, edit and lint tests.

Contributor checklist βœ…

  • The code has been linted using run mise run lint:fix
  • The change is tested via unit testing or acceptance testing, or both
  • The title of the PR is formulated in a way that is usable as a changelog entry
  • In case the PR introduces changes that affect users, the documentation has been updated

Reviewer checklist βœ…

  • The code architecture and patterns are consistent with the rest of the codebase
  • Reviewer has checked that, if needed, the PR includes the label changelog:added, changelog:fixed, or changelog:changed, and the title is usable as a changelog entry

@kapitoshka438 kapitoshka438 marked this pull request as ready for review April 12, 2024 22:28
@kapitoshka438 kapitoshka438 force-pushed the on-demand-resources branch 2 times, most recently from e284daa to 740d10e Compare April 13, 2024 22:07
Copy link
Collaborator

@kwridan kwridan left a comment

Choose a reason for hiding this comment

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

Thank you @kapitoshka438 for the detailed investigation into this!

@kapitoshka438 kapitoshka438 force-pushed the on-demand-resources branch 2 times, most recently from 6bad49f to f2767e3 Compare April 20, 2024 20:30
Copy link
Collaborator

@kwridan kwridan left a comment

Choose a reason for hiding this comment

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

Copy link
Collaborator

@kwridan kwridan left a comment

Choose a reason for hiding this comment

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

Thank you for all the updates @kapitoshka438

@kwridan
Copy link
Collaborator

kwridan commented Apr 23, 2024

@all-contributors add @kapitoshka438 for code

Copy link
Contributor

@kwridan

I've put up a pull request to add @kapitoshka438! πŸŽ‰

@kwridan kwridan added the changelog:added PR will be listed in the Added section of CHANGELOG label Apr 23, 2024
Copy link
Contributor

@pepicrft pepicrft left a comment

Choose a reason for hiding this comment

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

Some minor things. Thanks a lot for putting the work here.

@pepicrft
Copy link
Contributor

@kapitoshka438 would you mind adding a README.md where you document the fixture that you added? After adding it the README will automatically surface in the documentation website and it'll be useful for Tuist users to see some examples.

Copy link
Member

@fortmarek fortmarek left a comment

Choose a reason for hiding this comment

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

Amazing work πŸ‘

@fortmarek fortmarek merged commit a4909f2 into tuist:main May 6, 2024
8 checks passed
@kapitoshka438 kapitoshka438 deleted the on-demand-resources branch May 6, 2024 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:added PR will be listed in the Added section of CHANGELOG
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants