Is there any way to quit the iOS Simulator via a command line script?
有没有办法通过命令行脚本退出iOS模拟器?
Background:
I am setting up a Continous Integration environment to enable iOS builds to compile and be tested automatically. As part of this I am running scripts using Apple's UI Automation tool within Instruments.
我正在建立一个Continous Integration环境,以使iOS构建能够自动编译和测试。作为其中的一部分,我使用Apple的UI自动化工具运行脚本。
I've managed to automate the execution of the scripts on the iOS Simulator by running Instruments from the command line BUT now I now want to automate quitting of the Simulator.
我已经设法通过从命令行运行Instruments来自动执行iOS模拟器上的脚本但现在我现在想要自动退出模拟器。
I have tried some Apple Script similar to this post: How can I reset the iOS Simulator from the command line? but get the error "Access for assistive devices is disabled". Hopefully, there is a simpler way?
我尝试过类似这篇文章的Apple Script:如何从命令行重置iOS模拟器?但得到错误“禁用辅助设备访问”。希望有一种更简单的方法吗?
5 个解决方案
#1
20
killall "iOS Simulator"
in the Terminal will close it.
终端中的killall“iOS模拟器”将关闭它。
Also, you can launch it with iphonesim to have more control over it, including modifying the source to your needs.
此外,您可以使用iphonesim启动它以更好地控制它,包括根据您的需要修改源。
#2
21
For Xcode 7+ the command is killall "Simulator"
.
对于Xcode 7+,命令是killall“Simulator”。
#3
11
Try this:
osascript -e 'tell app "iOS Simulator" to quit'
#4
2
Pulling some of the commands together for XCode 6:
为XCode 6拉出一些命令:
killall "iOS Simulator"
xcrun simctl list | grep Booted | awk -F "[()]" '{ for (i=2; i<NF; i+=2) print $i }' | grep '^[-A-Z0-9]*$' | xargs -I uuid xcrun simctl shutdown uuid
xcrun simctl list | awk -F "[()]" '{ for (i=2; i<NF; i+=2) print $i }' | grep '^[-A-Z0-9]*$' | xargs -I uuid xcrun simctl erase uuid
open /Applications/Xcode.app/Contents/Developer/Applications/iOS\ Simulator.app
#5
-1
Based on that script you could create it like this:
基于该脚本,您可以像这样创建它:
tell application "iPhone Simulator"
activate
end tell
tell application "System Events"
tell process "iPhone Simulator"
tell menu bar 1
tell menu bar item "iOS Simulator"
tell menu "iOS Simulator"
click menu item "Quit iOS Simulator"
end tell
end tell
end tell
end tell
end tell
The assistive devices error would occur on this as well. To fix that you need to go to System settings, Universal access and check "Enable access for assistive devices"
辅助设备错误也会在此发生。要解决此问题,您需要转到系统设置,通用访问并选中“启用辅助设备访问”
#1
20
killall "iOS Simulator"
in the Terminal will close it.
终端中的killall“iOS模拟器”将关闭它。
Also, you can launch it with iphonesim to have more control over it, including modifying the source to your needs.
此外,您可以使用iphonesim启动它以更好地控制它,包括根据您的需要修改源。
#2
21
For Xcode 7+ the command is killall "Simulator"
.
对于Xcode 7+,命令是killall“Simulator”。
#3
11
Try this:
osascript -e 'tell app "iOS Simulator" to quit'
#4
2
Pulling some of the commands together for XCode 6:
为XCode 6拉出一些命令:
killall "iOS Simulator"
xcrun simctl list | grep Booted | awk -F "[()]" '{ for (i=2; i<NF; i+=2) print $i }' | grep '^[-A-Z0-9]*$' | xargs -I uuid xcrun simctl shutdown uuid
xcrun simctl list | awk -F "[()]" '{ for (i=2; i<NF; i+=2) print $i }' | grep '^[-A-Z0-9]*$' | xargs -I uuid xcrun simctl erase uuid
open /Applications/Xcode.app/Contents/Developer/Applications/iOS\ Simulator.app
#5
-1
Based on that script you could create it like this:
基于该脚本,您可以像这样创建它:
tell application "iPhone Simulator"
activate
end tell
tell application "System Events"
tell process "iPhone Simulator"
tell menu bar 1
tell menu bar item "iOS Simulator"
tell menu "iOS Simulator"
click menu item "Quit iOS Simulator"
end tell
end tell
end tell
end tell
end tell
The assistive devices error would occur on this as well. To fix that you need to go to System settings, Universal access and check "Enable access for assistive devices"
辅助设备错误也会在此发生。要解决此问题,您需要转到系统设置,通用访问并选中“启用辅助设备访问”