Issues with Swift Environment Variable Injector

environment-variable
#1

I’m having an issue with the Swift Environment Variable Injector and I’ve run out of ideas. I have a set of UI tests in my iOS app and they need a specific value to run these tests.

On my local machine, these are stored in Xcode Scheme environment variables. This works just fine.

On Bitrise, I added the values to the Env Var and Secrets for the app, and added the Swift Environment Variable Injector step before the testing step, but it does not seem to inject the values into the swift file. My Bitrise environment variable is called ENV_VAR_1 and the secret is SECRET_1. My swift file that is supposed to be updated looks like this:

import Foundation

struct CI {
static var var1: String = “$(ENV_VAR_1)”
static var secret1: String = “$(SECRET_1)”
static var testPath: String = “$(BITRISE_PROJECT_PATH)”
}

The only output I end up getting when I run the injector is just the original file (the example above). I even added the BITRISE_PROJECT_PATH to see if the injector would update that, but no luck.

Am I doing something wrong or misunderstanding how the Bitrise Env Vars can be used?

Thanks,
Josh

0 Likes

#2

Hey,

I came across a similar issue and I seem to remember that variables were note replaced when I was running a PR build in BitRise. I can’t remember if it was related to our secrets not exposed for PRs or to something different.

Are you running a PR build or a a branch build?

Cheers,
O

0 Likes

#3

Hey thanks for the reply.

I was able to figure it out, the default version of this Bitrise Step was 0.2.1, I had to manually change it to the latest - 0.3.3. After that it worked just fine.

Josh

0 Likes

closed #4

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.

0 Likes