Hey there,
I am currently struggling with this problem.
When running UI tests for my iOS application I want to acquire an authentication token from an API first, in order to be directly authenticated while the tests run. For using that API I need a client secret, which, because it's a secret, needs to be kept in a secure storage. I can't have that client secret be just somewhere plain text in code or any other unsecured file (xcconfig, plist, ...). That's why I want to put that client secret into macOS' key chain. I also already found out how to access that secret from command line in a build phase script (like security find-generic-password -l ClientSecret -g).
What I also know is how to use launch arguments or environment during UI testing (like ProcessInfo().environment["clientSecret"]).
But I can't seem to find a way to make the connection between an environment variable that I set in a build phase or run pre-action script like
I tried using that environment variable like clientSecret=$(CLIENTSECRET) in scheme's launch arguments or environment variables, but that doesn't work for me.
Is it even possible to access the bash runtime env variables from within the scheme's arguments? Is there some other way?
Or is there alternatively a chance for me to access the macOS system keychain from the UI test Swift code?
Anyone having an idea? Please help!
I am currently struggling with this problem.
When running UI tests for my iOS application I want to acquire an authentication token from an API first, in order to be directly authenticated while the tests run. For using that API I need a client secret, which, because it's a secret, needs to be kept in a secure storage. I can't have that client secret be just somewhere plain text in code or any other unsecured file (xcconfig, plist, ...). That's why I want to put that client secret into macOS' key chain. I also already found out how to access that secret from command line in a build phase script (like security find-generic-password -l ClientSecret -g).
What I also know is how to use launch arguments or environment during UI testing (like ProcessInfo().environment["clientSecret"]).
But I can't seem to find a way to make the connection between an environment variable that I set in a build phase or run pre-action script like
Code Block export CLIENTSECRET=$(security find-generic-password -l ClientSecret -w)
I tried using that environment variable like clientSecret=$(CLIENTSECRET) in scheme's launch arguments or environment variables, but that doesn't work for me.
Is it even possible to access the bash runtime env variables from within the scheme's arguments? Is there some other way?
Or is there alternatively a chance for me to access the macOS system keychain from the UI test Swift code?
Anyone having an idea? Please help!