Skip to content

Allow lookup template attributes from globalTemplateAttributes#1400

Open
vikage wants to merge 9 commits into
yonaskolb:masterfrom
vikage:master
Open

Allow lookup template attributes from globalTemplateAttributes#1400
vikage wants to merge 9 commits into
yonaskolb:masterfrom
vikage:master

Conversation

@vikage

@vikage vikage commented Sep 7, 2023

Copy link
Copy Markdown

This PR allow xcodegen to lookup template attributes from globalTemplateAttributes spec to share attributes accross all yaml files.
For example here, we have a shared today-extension-target.yml between multi project specs: legacy-project.yml and new-project.yml
We need to configure different config files between legacy and old. With this PR we just declare a version attribute from project spec and today-extension-target.yml can access it

Example
today-extension-target.yml

targetTemplates:
  TodayExtTemplate:
    platform: iOS
    type: app-extension
    settings:
      CODE_SIGN_IDENTITY: Apple Development
    configFiles:
      Debug: Config/${version}/Debug.xcconfig
      Release: Config/${version}/Release.xcconfig
    sources:
      - TodayExtension

targets:
  TodayExt:
    templates:
      - TodayExtTemplate

legacy-project.yml

name: Demo

options:
  createIntermediateGroups: True
  
globalTemplateAttributes:
  version: legacy

include:
  - today-extension-target.yml

targets:
  Demo:
    type: application
    platform: iOS
    deploymentTarget: "10.0"
    sources:
      - DemoXcodeGenGlobalTemplateAttribute

new-project.yml

name: Demo

options:
  createIntermediateGroups: True
  
globalTemplateAttributes:
  version: new

include:
  - today-extension-target.yml

targets:
  Demo:
    type: application
    platform: iOS
    deploymentTarget: "10.0"
    sources:
      - DemoXcodeGenGlobalTemplateAttribute

@vikage

vikage commented Sep 7, 2023

Copy link
Copy Markdown
Author

@yonaskolb @brentleyjones Please help me review this PR

@vikage vikage changed the title Allow lookup template variables from globalTemplateAttributes Allow lookup template attributes from globalTemplateAttributes Sep 7, 2023
@vikage

vikage commented Oct 3, 2023

Copy link
Copy Markdown
Author

@yonaskolb Please help me review this PR. Thanks

@yonaskolb

Copy link
Copy Markdown
Owner

I can see the utility in this @vikage. Got a few notes:

  • does the existing functionality of referencing environment variables in the spec also solve your issue? eg Config/${VERSION}/Debug.xcconfig and VERSION=new xcodegen generate
  • If this were added I can see this being useful just as globally accessible values, as opposed to restricting to just target or scheme templates. What do you think?
  • If this were moved forward, it would definitely need some unit tests, and an example in Tests/Fixtures/TestProject/project.yml

@vikage

vikage commented Oct 31, 2023

Copy link
Copy Markdown
Author

I can see the utility in this @vikage. Got a few notes:

  • does the existing functionality of referencing environment variables in the spec also solve your issue? eg Config/${VERSION}/Debug.xcconfig and VERSION=new xcodegen generate
  • If this were added I can see this being useful just as globally accessible values, as opposed to restricting to just target or scheme templates. What do you think?
  • If this were moved forward, it would definitely need some unit tests, and an example in Tests/Fixtures/TestProject/project.yml

@yonaskolb

  • Currently, exporting a variable on the command line could fix my issue. But I think it will be great if we have it in the yml config file.
  • If this was added, we could access variables globally without any restrictions.

If you are agree with this feature, I will implement an example and some unit tests

@yonaskolb

Copy link
Copy Markdown
Owner

Yes happy for you to move it forward, with the ability to reference these values anywhere and not just within templates

@vikage

vikage commented Oct 31, 2023

Copy link
Copy Markdown
Author

@yonaskolb I added unit test and example. Please help me review.
Thanks

@vikage

vikage commented Nov 3, 2023

Copy link
Copy Markdown
Author

@yonaskolb Please help me take a look

@vikage

vikage commented Jan 2, 2024

Copy link
Copy Markdown
Author

@yonaskolb Please review, thanks

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.

2 participants