iOS launch app with environment variable

2k views Asked by At

My app requires device UDID, but iOS simulator doesn't have one. So I want to pass a mock device UDID as a environment variable for simulator. I already know how to set environment variable in Xcode and it works fine when launching app from Xcode.
See tutorials:
nshipster: launch arguments and environment variables
cameronspickert: custom launch arguments and environment variables

However, when I try to launch app directly from simulator (not from Xcode), it seems no environment variables are passed to the app.

Question:
How to pass environment variable to app if launching app from simulator or device directly or even command line?

1

There are 1 answers

0
Jeremy Huddleston Sequoia On

The SIMULATOR_UDID environment variable contains the UDID of the simulated device, but you are probably doing something wrong if you try to use that as there is no direct analogy on device.

You can also setup your own environment variables by editing your scheme in Xcode.