Skip to content

Create interactive specs #273

Open
Open
@AliSoftware

Description

@AliSoftware

One use case I would have for XcodeGen would be to generate brand new projects when starting a new contract.

(For now we use liftoff for that but as it's not maintained anymore, we want to migrate to something else like XcodeGen)

The idea would be to create a project.yml with a magic syntax for values which, when encountered, would (1) interactively ask for the value to give to that setting (2) or allow for it to be specified via command line parameters (3) and once the project has been generated once, replace the values in the project.yml with the new ones

So, for example we could have a template.yml file like this:

name: "?name|App Name"
options: 
  createIntermediateGroups: true
  bundleIdPrefix: "?id|Bundle ID prefix"
  developmentLanguage: "en"
  usesTabs: false
  indentWidth: 2
  tabWidth: 2
  deploymentTarget:
    watchOS: "2.0"
    tvOS: "10.0"
    iOS: "?ios|Deployment Target|9.0"
settings:
    GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED: YES
    GCC_WARN_MISSING_PARENTHESES: YES
    GCC_WARN_ABOUT_RETURN_TYPE: YES
    GCC_WARN_CHECK_SWITCH_STATEMENTS: YES
    GCC_WARN_UNUSED_FUNCTION: YES
    GCC_WARN_UNUSED_LABEL: YES

targets:
  "?name":
    type: application
    
  UnitTests:
    type: bundle.unit-test

And then we could run the command, where we can provide values for all "?…" magic values, either using arguments via the command lines (using the parameter name provided next to the "?") or/and be interactively queried for others (using the second parameter provided after the "?…|" for the prompt, and the optional third part for the default value):

$ xcodegen --template="template.yml" --name=Foo
Bundle ID Prefix: com.mycompany
Deployment Target [9.0]: 9.3
> Generating project.yml from template.yml and the provided values…
> Generating Xcodeproj…

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions