open -a "Simulator"
注: xcode6 可能需要 open -a "iOS Simulator"
open -a "iOS Simulator" --args -CurrentDeviceUDID udid
udid 可以通过命令:xcrun simctl list 获得。
xcrun simctl install booted taobao.app
参数 booted 指的是当前启动的模拟器
xcrun simctl openurl booted taobao://h5.m.taobao.com/guang/index.html
Tips:taobao:// 是模拟器在安装 taobao.app 时注册的协议(scheme),当出现次协议的 URL 请求时默认会使用手机淘宝打开。
不同的 App 在系统注册的协议各不相同,需要根据实际情况填写。如果需要在 Safari 中打开直接用 http:// 协议头即可。
需要确保 设备 状态是 激活状态
xcrun simctl launch 945EFCEC-F84E-44AD-AE49-2E61EC7DA29B org.reactjs.native.example.wordShorthand2016
会返回 launched app 's pid
org.reactjs.native.example.wordShorthand2016: 11497
通过launch 返回的 pid
kill -9 pid
xcrun simctl launch ...
pcregrep -o1 表示,只输出捕获的 group(1)
BOOTED_DEVICE=`xcrun simctl list | pcregrep -o1 '\(([-a-zA-Z0-9]+)\)\s+\(Booted\)'`
APP_PATH=`find /Users/user/Library/Developer/CoreSimulator/Devices/$BOOTED_DEVICE/data/Containers/Bundle/Application -name "Info.plist" | grep nba_heroes | pcregrep -o1 '(.*?)/Info.plist'`
BOOTED_DEVICE=`xcrun simctl list | pcregrep -o1 '\(([-a-zA-Z0-9]+)\)\s+\(Booted\)'`
APP_BID='com.testnba.app'
PID_FILE='.pid_app'
kill -9 $(cat $PID_FILE)
xcrun simctl launch $BOOTED_DEVICE $APP_BID | grep -oE '\d+$' > $PID_FILE
cat $PID_FILE
xcrun simctl install booted /path/to/your.app