ideviceinstaller iOS真机自动化测试: 命令行安装App到手机并运行

安装 ideviceinstaller

brew install libimobiledevice  
brew install ideviceinstaller  

安装App到手机

ideviceinstaller -i   

常用命令

  -u, --udid UDID   Target specific device by UDID.
  -n, --network     Connect to network device.
  -l, --list-apps   List apps, possible options:
       -o list_user - list user apps only (this is the default)
       -o list_system   - list system apps only
       -o list_all  - list all types of apps
       -o xml       - print full output as xml plist
  -i, --install ARCHIVE Install app from package file specified by ARCHIVE.
                        ARCHIVE can also be a .ipcc file for carrier bundles.
  -U, --uninstall APPID Uninstall app specified by APPID.
  -g, --upgrade ARCHIVE Upgrade app from package file specified by ARCHIVE.
  -L, --list-archives   List archived applications, possible options:
       -o xml       - print full output as xml plist
  -a, --archive APPID   Archive app specified by APPID, possible options:
       -o uninstall - uninstall the package after making an archive
       -o app_only  - archive application data only
       -o docs_only - archive documents (user data) only
       -o copy=PATH - copy the app archive to directory PATH when done
       -o remove    - only valid when copy=PATH is used: remove after copy
  -r, --restore APPID   Restore archived app specified by APPID
  -R, --remove-archive APPID  Remove app archive specified by APPID
  -o, --options     Pass additional options to the specified command.
  -w, --notify-wait     Wait for app installed/uninstalled notification
                            to before reporting success of operation
  -h, --help        prints usage information
  -d, --debug       enable communication debugging
  -v, --version     print version information

1、打印app列表

ideviceinstaller -l

2、查看当前已连接的设备的UUID

idevice_id -l

3、获取设备信息

ideviceinfo

4、获取设备时间

idevicedate

5、重启设备

idevicediagnostics restart

6、安装ipa包,卸载应用

ideviceinstaller -i xxx.ipa //命令安装一个ipa文件到手机上,如果是企业签名的,非越狱机器也可以直接安装了。
ideviceinstaller -U [bundleID] //命令卸载应用,需要知道此应用的bundleID

7、查看系统日志

idevicesyslog  //屏幕上即可看见手机上所有的日志

idevicesyslog >> iphone.log &
//该命令是将日志导入到iphone.log这个文件,并且是在后台执行。
//然后用tail -f和grep查看log
tail -f iphone.log
tail -f iphone.log | grep 'WeChat’  # 查看包含WeChat的行

8、截图

idevicescreenshot
//如果在使用截图的时候出现报错信息,那么就去把相应版本的DeveloperDiskImage的两个文件复制到libimobiledevice文件下面。

路径:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/对应版本/

获取版本号命令:
ideviceinfo -k ProductVersion

安装DeveloperDiskImage命令:
ideviceimagemounter DeveloperDiskImage.dmg
//然后就可以正常截图了

你可能感兴趣的:(ideviceinstaller iOS真机自动化测试: 命令行安装App到手机并运行)