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

[CI-2849] Resolve env vars with xcodebuild #44

Merged
merged 2 commits into from
Apr 25, 2024

Conversation

tothszabi
Copy link
Contributor

Checklist

  • I've read and followed the Contribution Guidelines
  • step.yml and README.md is updated with the changes (if needed)

Version

Requires a PATCH version update

Context

When you create a new project the default setting for the Info.plist file in your build settings is a relative path from the project file. But this can be freely overridden by the user and for example we could have something like this there:

$(SRCROOT)/path/to/Info.plist

A value with an embedded env var which can be only resolved by Xcode. This is just one example as there are multiple Xcode env vars. The step needs to handle these cases as well.

The simplest solution is to check if the returned value contains an env var. If it does then use xcodebuild -showBuildSettings to list all of the build settings. When we are doing this then Xcode will resolve all of the env vars.

I need to mention that this will be a fallback mechanism because this xcodebuild command can take a lot of time for larger projects.

I have updated one of the e2e test projects to have it's Info.plist path defined with an env var.

step/step.go Show resolved Hide resolved
"github.com/bitrise-io/go-utils/v2/log"
"github.com/bitrise-io/go-xcode/v2/autocodesign/projectmanager"
"github.com/bitrise-io/go-xcode/xcodeproject/xcodeproj"
)

const (
infoPlistFileKey = "INFOPLIST_FILE"
envVarRegex = `^.*\$\(.+\).*$`
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI I was curious and checked if it handles nested env vars. I'm not sure if it's even handled by Xcode, but it works 😄
image

@tothszabi tothszabi merged commit bc98277 into master Apr 25, 2024
1 check passed
@tothszabi tothszabi deleted the CI-2849-handle-env-vars branch April 25, 2024 13:13
@lpusok lpusok mentioned this pull request May 17, 2024
1 task
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