yonaskolb / yonaskolb/XcodeGen
Source an environment within the preGenCommand or include .env.yml file and use variables through the script
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 8.8k
- Forks
- 908
- Avg merge
- 17d 14h
- Merged PRs (30d)
- 2
Description
Hello all,
I was looking for a way to be able to source a local .env file from within the project.yml so that it doesn't need to be done on a per terminal/added to .bash_profile on the users machine. I was hoping the following would work but it doesn't.
.env
ENVIRONMENT=local
project.yml
...
options:
# Command that runs before creating the xcproject
preGenCommand: |
source .env
...
targets:
TARGET_NAME:
scheme:
environmentVariables:
ENVIRONMENT: ${ENVIRONMENT}
Should this be possible? It seems like the preGenCommand runs in it's own container and doesn't run in the same container that is used for the environment.
I also looked at using a separate yml file for the environment but the variables aren't working either.
.env.yml
ENVIRONMENT: local
project.yml
...
include:
- .env.yml
...
targets:
TARGET_NAME:
scheme:
environmentVariables:
ENVIRONMENT: ${ENVIRONMENT}
but the variable doesn't fill in either instance. Any thoughts on this would be greatly appreciated.
xcodegen --version
Version: 2.24.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the .env and .env.yml examples with XcodeGen 2.24.0, then trace how preGenCommand, included YAML files, and ${ENVIRONMENT} interpolation are processed. Compare the command's environment with the later scheme generation step; done means a documented, tested way to make the variable available to environmentVariables.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- shell, swift, yaml
- Domain
- build-system, cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100