简体   繁体   English

如何在构建设置中的运行脚本阶段检查设备类型(设备/模拟器)?

[英]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.

相关问题 如何在构建阶段访问Xcode用户从运行脚本定义构建设置? - How to access Xcode user define build settings from run script in build phase? Xcode构建设置,模拟器与设备的环境变量 - Xcode build settings, environment variables for simulator vs device 如何在xcode 7模拟器或设备上运行应用程序? - how to run app on xcode 7 simulator or device? 如果构建中断,如何使XCode运行脚本构建阶段运行? - How to make XCode Run Script Build Phase run if the build breaks? Xcode:一步一步为iOS Simulator和Device构建并运行? - Xcode: build and run for both iOS Simulator and Device in one step? Xcode将在模拟器上构建项目,但不在设备上构建 - Xcode will build project on simulator but not on device TwitterText Framework在模拟器上运行,而不在设备上运行 - TwitterText Framework run on simulator, not on device Xcode 将在模拟器上运行应用程序但不在设备上 - Xcode will run app on simulator but not on device Xcode构建阶段-运行脚本。 如何在方案中定义变量以在构建阶段脚本中读取? - Xcode Build Phase - Run Script. How to define a variable in a scheme to read at build phase script? 应用程序设置出现在模拟器中,但不会显示在设备上 - App settings appear in simulator but wont on device
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM