How to check type of device (device/simulator) on Run Script phase in Build Settings?

493 Views Asked by At

I have 2 versions of some library, one - for real device, other - for simulator. Can I write sh script to detect on which device (device/sim) Xcode will run application and switch that libraries in Run Script phase?

1

There are 1 best solutions below

0
On BEST ANSWER

When your script executed list of environment variables available. One of them is __IS_NOT_SIMULATOR.

When building for simulator it have this value:

export __IS_NOT_SIMULATOR\=NO

When building for device it have this value:

export __IS_NOT_SIMULATOR\=YES

In build script it can be accessed like this:

echo "IS_NOT_SIMULATOR = ${__IS_NOT_SIMULATOR}"