ios-deploy也是一个终端安装和调试iPhone应用的是第三方开源库,使用时需要开发者证书和Xcode7以上版本。
1. 安装ios-deploy
我们用npm
来安装ios-deploy
,如果Mac上没有,先安装node
:
brew install node
安装node
干甚?因为现在版本比较新的node
都自带npm
哇。
接下来愉快地安装ios-deploy
:
npm install -g ios-deploy
2. ios-deploy常用命令
2.1 查看连接的设备(包括通过usb和wifi连接的)
ios-deploy -c
2.2 查看通过usb连接的设备
ios-deploy -c --no-wifi
2.3 安装应用到指定设备(其中xxx.app是Xcode编译后的ipa的路径)
ios-deploy --id [udid] --bundle [xxx.app]
2.4 卸载指定设备上的应用(根据包名,也就是bundleId)
ios-deploy --id [udid] --uninstall_only --bundle_id [bundleId]
2.5 查看指定设备上安装的所有应用(包括系统应用和第三方)
ios-deploy --id [udid] --list_bundle_id
2.6 检查指定设备上是否安装了某个应用
ios-deploy --id [udid] --exists --bundle_id
3. ios-deploy的帮助项(Option):
-d, --debug launch the app in lldb after installation
-i, --id <device_id> the id of the device to connect to
-c, --detect only detect if the device is connected
-b, --bundle <bundle.app> the path to the app bundle to be installed
-a, --args <args> command line arguments to pass to the app when launching it
-t, --timeout <timeout> number of seconds to wait for a device to be connected
-u, --unbuffered don't buffer stdout
-n, --nostart do not start the app when debugging
-I, --noninteractive start in non interactive mode (quit when app crashes or exits)
-L, --justlaunch just launch the app and exit lldb
-v, --verbose enable verbose output
-m, --noinstall directly start debugging without app install (-d not required)
-p, --port <number> port used for device, default: dynamic
-r, --uninstall uninstall the app before install (do not use with -m; app cache and data are cleared)
-9, --uninstall_only uninstall the app ONLY. Use only with -1 <bundle_id>
-1, --bundle_id <bundle id> specify bundle id for list and upload
-l, --list list files
-o, --upload <file> upload file
-w, --download download app tree
-2, --to <target pathname> use together with up/download file/tree. specify target
-D, --mkdir <dir> make directory on device
-R, --rm <path> remove file or directory on device (directories must be empty)
-V, --version print the executable version
-e, --exists check if the app with given bundle_id is installed or not
-B, --list_bundle_id list bundle_id
-W, --no-wifi ignore wifi devices
--detect_deadlocks <sec> start printing backtraces for all threads periodically after specific amount of seconds
4,命令使用详解
- idevice_id --list # 显示当前所连接设备的 udid
- instruments -s devices # 列出所有设备,包括真机、模拟器、mac
- ideviceinfo 可以在返回的数据中找到 udid
- ideviceinstaller -i apppath 安装apppath下的app
- ideviceinstaller -u [udid] -i [xxx.ipa] # xxx.ipa 为应用在本地的路径
- ideviceinstaller -u [udid] -U [bundleId]卸载应用
查看设备已安装的应用 - ideviceinstaller -u [udid] -l # 查看设备安装的第三方应用
- ideviceinstaller -u [udid] -l -o list_user # 同上,查看设备安装的第三方应用
- ideviceinstaller -u [udid] -l -o list_system # 查看设备安装的系统应用
- ideviceinstaller -u [udid] -l -o list_all # 查看设备安装的所有应用获取设备信息
- idevicedate 获取设备时间
- ideviceinfo -u [udid] # 获取设备信息
- ideviceinfo -u [udid] -k DeviceName # 获取设备名称 同命令 idevicename
- idevicename # 同上
- ideviceinfo -u [udid] -k ProductVersion # 获取设备版本 10.3.3
- ideviceinfo -u [udid] -k ProductType # 获取设备类型 iPhone 8,1
- ideviceinfo -u [udid] -k ProductName # 获取设备系统名称
其他系统文件信息 - ideviceinfo # 获取设备所有信息
- idevicesyslog # 获取设备日志
- idevicesyslog -u [udid] > /Users/home/Desktop/log.log # 将日志输出到指定路径
- idevicecrashreport -e test # 获取设备 crashlog,test 是文件夹需新建
- idevicediagnostics # 管理设备状态 - 重启、关机、睡眠等
ios-deploy 常用命令 - ios-deploy -c # 查看当前链接的设备
- ios-deploy --[xxx.app] # 安装APP
- ios-deploy --id [udid] --uninstall_only --bundle_id [bundleId] # 卸载应用
- ios-deploy --id [udid] --list_bundle_id # 查看所有应用
- ios-deploy --id [udid] --exists --bundle_id # 查看应用是否安装
列举设备安装的应用: - ideviceinstaller -l则可以列出手机上所有的用户安装的app
运行某个app - idevicedebug run 'APP_BUNDLE_ID'可以直接launch某个app,当然,这个app必须是你通过development证书build到手机上的才行。
获取手机的设备版本: - Ideviceinfo -k ProductVersion
获取手机的设备名: - ideviceinfo -k ProductType
截图: - idevicescreenshot
- idevicescreenshot /Users/medivh/Desktop/a.png # 将文件输入到指定路径
- xrecord --quicktime --id="你的手机uid" --out="/Users/ycf/Documents/产品/csap/test/hot/iphone.mp4" --force #手机屏幕录制