xcode 如何从命令行安装 iOS 模拟器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34493934/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to install iOS simulators from command line
提问by Quanlong
It's a common case to run tests against different versions of iOS simulators/SDKs on CI. However, only the latest iOS simulator is installed by Xcode on default.
在 CI 上针对不同版本的 iOS 模拟器/SDK 运行测试是一种常见情况。但是,Xcode 默认只安装最新的 iOS 模拟器。
So I need install other missing iOS simulators from command line in CI environment. But I cannot find a way to install those simulators from command line.
所以我需要在 CI 环境中从命令行安装其他缺少的 iOS 模拟器。但是我找不到从命令行安装这些模拟器的方法。
回答by Quanlong
It can be done with xcode-install, with the following commands
可以使用xcode-install 完成,使用以下命令
gem install xcode-install
xcversion simulators --install='iOS 9.3'
回答by iPrabu
FYI
供参考
All simulators are packed with Xcode app. Instead of installing simulators you can just install the specific Xcode versions. Xcode7.0 has iOS9 Simulators Xcode6.4 has iOS8.x Simulators
所有模拟器都装有 Xcode 应用程序。您可以安装特定的 Xcode 版本,而不是安装模拟器。Xcode7.0 有 iOS9 模拟器 Xcode6.4 有 iOS8.x 模拟器
In your CI testing if you want to test you app for a specific simulator just select xcode version before you do the xcodebuild command
在您的 CI 测试中,如果您想针对特定模拟器测试您的应用程序,只需在执行 xcodebuild 命令之前选择 xcode 版本
xcode-select -switch <path to your xcode app>
This will set your default xcode to run the xcodebuild Then run the xcodebuild with your respective simulator.
这将设置您的默认 xcode 以运行 xcodebuild 然后使用您各自的模拟器运行 xcodebuild。
xcodebuild -configuration ${BUILD_TYPE} -target ${TARGET_NAME} -arch ${CPU_ARCHITECTURE} -sdk ${SIMULATOR_OR_IOS_SDK}
In the place of SIMULATOR_OR_IOS_SDK
give your simulator value.
代替SIMULATOR_OR_IOS_SDK
给你的模拟器值。
You can find the simulator value by running
您可以通过运行找到模拟器值
xcodebuild -showsdks
This will show like
这将显示为
OS X SDKs:
OS X 10.11 -sdk macosx10.11
iOS SDKs:
iOS 9.1 -sdk iphoneos9.1
iOS Simulator SDKs:
Simulator - iOS 9.1 -sdk iphonesimulator9.1
tvOS SDKs:
tvOS 9.0 -sdk appletvos9.0
tvOS Simulator SDKs:
Simulator - tvOS 9.0 -sdk appletvsimulator9.0
watchOS SDKs:
watchOS 2.0 -sdk watchos2.0
watchOS Simulator SDKs:
Simulator - watchOS 2.0 -sdk watchsimulator2.0
This way you can build your project on any specific device/simulator/os.
通过这种方式,您可以在任何特定设备/模拟器/操作系统上构建您的项目。
Hope this helps :)
希望这可以帮助 :)
回答by Quanlong
For iOS 8.1 Simulator: http://devimages.apple.com/downloads/xcode/simulators/com.apple.pkg.iPhoneSimulatorSDK8_1-8.1.1.1434581536.dmg
对于 iOS 8.1 模拟器:http: //devimages.apple.com/downloads/xcode/simulators/com.apple.pkg.iPhoneSimulatorSDK8_1-8.1.1.1434581536.dmg
For iOS 8.2 Simulator: http://devimages.apple.com/downloads/xcode/simulators/com.apple.pkg.iPhoneSimulatorSDK8_2-8.2.1.1434581536.dmg
对于 iOS 8.2 模拟器:http: //devimages.apple.com/downloads/xcode/simulators/com.apple.pkg.iPhoneSimulatorSDK8_2-8.2.1.1434581536.dmg
For iOS 8.3 Simulator: http://devimages.apple.com/downloads/xcode/simulators/com.apple.pkg.iPhoneSimulatorSDK8_3-8.3.1.1434581536.dmg
对于 iOS 8.3 模拟器:http: //devimages.apple.com/downloads/xcode/simulators/com.apple.pkg.iPhoneSimulatorSDK8_3-8.3.1.1434581536.dmg
For iOS 8.4 Simulator: http://devimages.apple.com/downloads/xcode/simulators/com.apple.pkg.iPhoneSimulatorSDK8_4-8.4.1.1435785476.dmg
对于 iOS 8.4 模拟器:http: //devimages.apple.com/downloads/xcode/simulators/com.apple.pkg.iPhoneSimulatorSDK8_4-8.4.1.1435785476.dmg
I don't know where these URLs come from, but I found some clues
我不知道这些 URL 来自哪里,但我找到了一些线索
回答by RY Zheng
xcrun simctl create <name> <device type> <runtime>
For example:
例如:
xcrun simctl create "ry" "iPhone 11 Pro Max" iOS13.3
xcrun simctl
is command utils to control iOS simulator, just like adb
for Android. You can also run xcrun simctl help
, there are a bundle of useful subcommands. When successful, most of these commands exit with 0; when failed, most exit with a non-zero number.
xcrun simctl
是控制iOS模拟器的命令工具,就像adb
Android一样。您也可以运行xcrun simctl help
,有一堆有用的子命令。成功时,这些命令中的大多数以 0 退出;失败时,大多数以非零数字退出。