libiphone(macOS 10.14.5)

起因:

最近在研究自动化测试方案, 在10.14.5上安装libimobiledevice期间遇到了些问题
libimobiledevice

起初在配置MacacaAppium等环境的时候并没有发现什么问题, 一些配置都是手填的, 前期主要是快速搭建环境跑起来体验对比, 当时在通过ideviceinstaller获取信息时遇到了报错:

$ ideviceinstaller -l
"Could not connect to lockdownd. Exiting."

暂时先放着跳过没处理, 基本情况就是本身苹果不支持Linux, 这个工具是一些Linux大牛破解iOSmac OS通信协议而搞出来的一套工具库, 可以在Linux上搞iOS设备, mac OS更新后, 协议上有些调整, 导致部分功能出现了异常

简单的了解了MacacaAppiumSoloπATXAthrunAirTest等十多个自动化测试方案后, 侧重于UI测试,如游戏的新手教程,需求:

  • 支持iOSAndroid, 支持H5
  • 支持游戏 (H5手游, 原生基于Unity3DUE4)
  • 支持录制生成脚本, 回归测试 (毕竟我不是写自动化的, 也是为了效率)
  • 非侵入式, 不需要源码, 只提供.ipa.apk即可完成自动化测试 (干死一大片, 比如比较看好的网易和腾讯提供的游戏自动化方案)

然后就是体验环节遗留的问题看能否处理解决

localhost:Desktop shenyj$ idevicescreenshot
ERROR: Could not connect to lockdownd, error code -17
localhost:Desktop shenyj$ ideviceinfo
ERROR: Could not connect to lockdownd, error code -19
localhost:Desktop shenyj$ ideviceinfo
ERROR: Could not connect to lockdownd, error code -21
localhost:Desktop shenyj$ ideviceinfo
ERROR: Could not connect to lockdownd, error code -19
localhost:Desktop shenyj$ idevicedate
ERROR: Could not connect to lockdownd, error code -21
localhost:Desktop shenyj$ idevicename
ERROR: Could not connect to lockdownd, error code -21
localhost:Desktop shenyj$ ideviceinstaller -l
Could not connect to lockdownd. Exiting.

回过头来就是先要把libimobiledevice系统更新后部分功能失效的问题解决, 在公司电脑上折腾了一天, 最后还是没能修复, 因为电脑配置了很多环境, 也不清楚是否整个环境出了问题, 下班回家用自己电脑安装, 虽然遇到了同样的问题, 但是根据先卸载, 再重装新版本依赖插件的步骤, 几分钟就解决了, 所以简单的整理下过程, 明天到了公司重新试一遍.

大致过程就是, 当你在遇到这个问题后, 网上给出的答案基本都是:

  1. 先忽略依赖关系强行卸载插件
  2. 重装当前插件的最新版本

如果卸载完后, 直接这样安装libimobiledevice的时候

$ brew install --HEAD libimobiledevice

会先去安装依赖

==> Installing dependencies for libimobiledevice: autoconf, automake, libtool and libxml2

到了执行autogen.sh这个脚本的时候, 问题来了:

==> ./autogen.sh
Last 15 lines from /Users/shenyj/Library/Logs/Homebrew/libimobiledevice/01.autogen.sh:
checking dynamic linker characteristics... darwin18.6.0 dyld
checking how to hardcode library paths into programs... immediate
checking for pkg-config... /usr/local/opt/pkg-config/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for libusbmuxd >= 1.1.0... no
configure: error: Package requirements (libusbmuxd >= 1.1.0) were not met:

Requested 'libusbmuxd >= 1.1.0' but version of libusbmuxd is 1.0.10

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables libusbmuxd_CFLAGS
and libusbmuxd_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

READ THIS: https://docs.brew.sh/Troubleshooting

关键信息:

Requested 'libusbmuxd >= 1.1.0' but version of libusbmuxd is 1.0.10

告诉了我们某个系统组件版本过低, 按照网上的方案卸载后, 不要直接安装最新的libimobiledevice, 先把报错版本低的依赖组件更新, 稳妥一点, 先unlink后重新link一下
正确的步骤如下:

$ brew uninstall --ignore-dependencies libimobiledevice
$ brew uninstall --ignore-dependencies usbmuxd
$ brew install --HEAD usbmuxd
# 这两句如果你不想分成两次执行,也可以合并brew unlink usbmuxd && brew link usbmuxd
$ brew unlink usbmuxd
$ brew link usbmuxd
# 最后在执行安装libimobiledevice
$ brew install --HEAD libimobiledevice

我办公电脑的环境有所不同, 在执行脚本提示libusbmuxd版本的地方, 按照这个思路来, 哪个版本低更新哪个 , 还会遇到libplist.... 一串问题,
麻烦的是libimobiledevice有很多依赖, 包括工具插件和系统级组件:

libplist
libtool
usbmuxd(或libusbmuxd)
openssl (版本需要大于0.9.8) 或 GnuTLS ✅

# 以下这些依赖基本系统已经有了
make
autoheader
automake
autoconf
pkg-config
gcc 或 clang  ✅

因为试了很多次卸载重装libimobiledevice组件无效(期间也会因网络原因出现其他错误) , 打算clone各个模块本地编译安装, 这里面只有俩个我没发现有问题的, 其余都有看到报错字样


后续

第二天来先按照昨天的有效思路执行了一遍 --> 无效
有点不理解的是,思路上是先忽略掉依赖关系强制卸载,并且先安装usbmuxd,因为usbmuxdlibimobiledevice的依赖,但usbmuxd旧版本能安装,新版本装不上

Last 15 lines from /Users/Shen/Library/Logs/Homebrew/usbmuxd/01.autogen.sh:
checking dynamic linker characteristics... darwin18.6.0 dyld
checking how to hardcode library paths into programs... immediate
checking for pkg-config... no
checking for libplist >= 1.11... no
configure: error: in `/private/tmp/usbmuxd-20190731-97006-n6t6t9':
configure: error: The pkg-config script could not be found or is too old.  Make sure it
is in your PATH or set the PKG_CONFIG environment variable to the full
path to pkg-config.

Alternatively, you may set the environment variables libplist_CFLAGS
and libplist_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

To get pkg-config, see .
See `config.log' for more details

还是pkkg-config有问题,添加过路径,那只能是版本低了

重装/更新 组件
确认本地环境都已经安装

make✅
autoheader✅
automake✅
autoconf✅
pkg-config✅
gcc ✅

这次不光是把pkg-config更新了,来了个全套升级,再试 --> 无效

既然brew的方式无法安装,也都更新过了,再试试clone本地编译
这里有个有趣的现象
我先编译安装libimobiledevice,会提示我找不到libusbmuxd

checking for libusbmuxd >= 1.1.0... no
configure: error: Package requirements (libusbmuxd >= 1.1.0) were not met:
No package 'libusbmuxd' found

于是先编译安装usbmuxd,会提示我找不到libimobiledevice

configure: error: preflight worker support requested but libimobiledevice could not be found

--HEAD的方式安装libimobiledevice会提示usbmuxd版本低,那我先安装个低版本libimobiledevice在编译usbmuxd试试,结果一样找不到

configure: error: preflight worker support requested but libimobiledevice could not be found
  • libusbmuxd 是usbmuxd的依赖; 其实这里我应该先编译安装libusbmuxd试试的,但是过后看了下依赖关系,在我编译安装libusbmuxd 前,我可能还得先编译安装libplist , 而最后还会因为pkg-config版本的关系导致编译安装失败, 浪费时间

Stack Overflow搜了下,看到一个有关usbmudx报错的贴 链接 , 建议用port来安装

libiphone(macOS 10.14.5)_第1张图片
answer.png

时间有点久, 当时port上指定的是1.0.7版本,没用过port, 打算试一试,在安装port过程中(时间有点长)

之前在github上有看过版本, 等待期间又去HomeBrew检查了下当前挂的最新版本状态:

libiphone(macOS 10.14.5)_第2张图片
libimobiledevice-version.png

libiphone(macOS 10.14.5)_第3张图片
usbmuxd-version.png

从这来看, libimobiledevice已经是新版本了, usbmuxd仍不是最新版本
又顺带着看了下其他依存组件
pkg-config --> 0.29.2

然后检查了下本地环境版本:

$ pkg-config --version

0.28

$ brew upgrade pkg-config

Error: pkg-config 0.29.2 already installed

折腾了这么久,终于找到了这台机器安装失败的根源...

$ brew unlink pkg-config && brew link pkg-config

Unlinking /usr/local/Cellar/pkg-config/0.29.2... 1 symlinks removed
Linking /usr/local/Cellar/pkg-config/0.29.2... 
Error: Could not symlink bin/pkg-config
Target /usr/local/bin/pkg-config
already exists. You may want to remove it:
  rm '/usr/local/bin/pkg-config'

To force the link and overwrite all conflicting files:
  brew link --overwrite pkg-config

To list all files that would be deleted:
  brew link --overwrite --dry-run pkg-config

这里直接unlinklink的方式行不通,给了建议操作

$ brew link --overwrite pkg-config

Linking /usr/local/Cellar/pkg-config/0.29.2... 4 symlinks created

在检查下版本:

# 稳妥起见,又link了一次,因为已经link过了,所以系统按照系统建议有操作了一次
$ brew link pkg-config

Warning: Already linked: /usr/local/Cellar/pkg-config/0.29.2
To relink: brew unlink pkg-config && brew link pkg-config

$ brew unlink pkg-config && brew link pkg-config
Unlinking /usr/local/Cellar/pkg-config/0.29.2... 4 symlinks removed
Linking /usr/local/Cellar/pkg-config/0.29.2... 4 symlinks created
# 检查版本 遇到权限问题
$ pkg-config --version
-bash: /usr/local/bin/pkg-config: Permission denied
# 授权
$ sudo chmod 777 /usr/local/bin/pkg-config
Password:

# 添加权限后再来确认版本 
$ pkg-config --version
0.29.2

这次直接用brew安装最新的usbmuxd试试

brew install --HEAD usbmuxd

执行到/autogen.sh停了一下然后过了无报错, 感觉有戏,稍微等了一小会,最终成功安装,接着安装libimobiledevice
整个操作过程完整截图:

libiphone(macOS 10.14.5)_第4张图片
pkg-config版本问题.png

最后把ideviceinstaller装上, 成功获取手机所有已安装App BundleID

libiphone(macOS 10.14.5)_第5张图片
pass.png

你可能感兴趣的:(libiphone(macOS 10.14.5))