Jxtt
Jxtt

Reputation: 137

iOS launch app with environment variable

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?

Upvotes: 4

Views: 2143

Answers (1)

Jeremy Huddleston Sequoia
Jeremy Huddleston Sequoia

Reputation: 23623

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.

Upvotes: 1

Related Questions