XcodeGen icon indicating copy to clipboard operation
XcodeGen copied to clipboard

Specify additional build/run targets for target-scheme

Open Uki19 opened this issue 1 year ago • 2 comments

Similarly to testTargets, it would be useful to be able to define additional targets within target-scheme.

For example, Widgets target scheme should have AppTarget added as build target, but currently it doesn't seem possible.

targets:
  AppTarget:
     ...
     
  Widgets:
      type: app-extension
      subtype: widgetkit-extension
      platform: iOS
      deploymentTarget: 15.0
      configFiles:
        DEV Debug: some-dev.xcconfig
        DEV Release: some-dev.xcconfig
        PROD Debug: some-prod.xcconfig
        PROD Release: some-prod.xcconfig
      scheme:
        configVariants:
          - DEV
          - PROD

It is possible to do using top level scheme, but since we have 3+ configVariants in 3+ app "flavours" (whitelabel app), we'd like to rely on using configVariants and avoid manually specifying scheme for each target/config/flavour combination

Uki19 avatar Feb 27 '24 10:02 Uki19

@Uki19 do you have a proposal for how this would look? Also if using the more fully featured schemes is difficult, there are also scheme templates that may cut down on the boilerplate required for you, if you weren't aware of them https://github.com/yonaskolb/XcodeGen/blob/master/Docs/ProjectSpec.md#scheme-template

yonaskolb avatar Apr 07 '24 12:04 yonaskolb

for example, there could be buildTargets or additionalTargets, like there's testTargets option:

targets:
  AppTarget:
     ...
     
  Widgets:
      type: app-extension
      subtype: widgetkit-extension
      platform: iOS
      deploymentTarget: 15.0
      configFiles:
        DEV Debug: some-dev.xcconfig
        DEV Release: some-dev.xcconfig
        PROD Debug: some-prod.xcconfig
        PROD Release: some-prod.xcconfig
      scheme:
        configVariants:
          - DEV
          - PROD
        buildTargets: <-- here
           - AppTarget: all
           - AppIntentsExtension: all
           ...

AppTarget name could be derived via target_name variable, or passed in as templateAttributes:

// templates:
Widgets:
    ...
    buildTargets: <-- here
      - ${mainTargetName}: all
      - ${mainTargetName}ntentsExtension: all

// actual targets:
targets:
    AppWidgets:
       templates:
         - Widgets
       templateAttributes:
         mainTargetName: App

We ended up using schemeTemplates for now which did reduce the boilerplate, but this could help us improve it even further 🙂

Uki19 avatar Apr 08 '24 12:04 Uki19