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 <http://pkg-config.freedesktop.org/>.
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来安装

answer.png

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

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

libimobiledevice-version.png

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
整个操作过程完整截图:

pkg-config版本问题.png

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

pass.png

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 158,560评论 4 361
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,104评论 1 291
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 108,297评论 0 243
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 43,869评论 0 204
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,275评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,563评论 1 216
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,833评论 2 312
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,543评论 0 197
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,245评论 1 241
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,512评论 2 244
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,011评论 1 258
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,359评论 2 253
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,006评论 3 235
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,062评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,825评论 0 194
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,590评论 2 273
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,501评论 2 268