[英]How to check type of device (device/simulator) on Run Script phase in Build Settings?
I have 2 versions of some library, one - for real device, other - for simulator.我有一些库的 2 个版本,一个用于真实设备,另一个用于模拟器。 Can I write sh script to detect on which device (device/sim) Xcode will run application and switch that libraries in Run Script phase?我可以编写 sh 脚本来检测 Xcode 将在哪个设备(设备/sim)上运行应用程序并在运行脚本阶段切换该库吗?
When your script executed list of environment variables available.当您的脚本执行时可用的环境变量列表。 One of them is __IS_NOT_SIMULATOR .其中之一是__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}"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.