Closed jpipearagon closed 4 years ago
Hey @jpipearagon :)
Humm, the variable to be replaced has to be set on your system via terminal or .bash_profile initialization(and optionally if you want are GUI or CLI processes to see those variables, make sure to set those variables on lauchctl
and then restart Xcode process).
Those Xcode Environment Variable parameters you have set are passed to the Process (App) at launch time and not at compile time. Meaning that you launch the process with those arguments, that you are only going to have those values if you run the project with Xcode.
With that said to be able to run the variable injector on the terminal and see the replacement, you would have to set those variables in your system, not on Xcode.
Ok thanks! I already worked on the terminal.
But in Xcode it doesn't work for me, Add Run script before compiling:
and also add environment variable:
my code looks like this:
struct CI { static var country: String = "$(RPPAY_COUNTRY)" }
when I run from xcode it works, but when I run the compile it looks like this:
I need to add the variable somewhere to make it work in Xcode?
Ahh, Xcode is what we call GUI process so to have environment variables available to the Xcode process, you have to make sure to set those variables on lauchctl
and then restart Xcode process. You can see more details on this SO thread. I should probably highlight this on the article :)
Yes, you are a "crack" :) I already worked with your reference. Yes, it would be good if you added the reference to the article.
Lastly I want to ask you the last question in bitrise it would only work by adding the environment variables or the variables have to be secret variables:
something like that in bitrise.yml
:
`envs:
Lastly I want to ask you the last question in bitrise it would only work by adding the environment > variables or the variables have to be secret variables:
I think it doesn't make any difference, in this case, both secrets and env var are set as an environment variable when the build launches, the only difference is access level, secrets are encrypted and more constrained(they are only visible at the time of builds).
thanks, I already made the changes, but it doesn't work in bitrise:
add the variable:
but the script log:
any ideas, can i check something?
Are you using the lastest version? For XCode 11.3 try to downgrade to the version before that... that’s the only thing I can think now
Awesome thanks, i just had to downgrade the version.
i run the script in terminal
variable-injector --file ${SRCROOT}TestInjector/SwiftInjector/CI.swift --verbose
but it only prints
`======================================================================
FILE: CI.swift
======================================================================
// // CI.swift // TestInjector // // Created by Felipe Aragon on 22/04/20. // Copyright © 2020 Felipe Aragon. All rights reserved. //
import Foundation
struct CI { static var rappiPayCountry: String = "$(COUNTRY)" } ` and the set of the variable is not done
I don't know what happens....