问题引入
iOS自动化测试或者性能测试过程中,有不少场景是需要检测设备的日志信息。
甚至还需要提取其中的业务日志进行进一步分析。
那么就需要一个工具来摆脱手动拷贝日志的糟糕情况。
可行性分析
Xcode-Windows-Device 可以看到当前连接设备的运行日志
iTools、PP助手等第三方程序可以获取当前连接设备的运行日志
开源项目
https://github.com/benvium/libimobiledevice-macosx 可执行方案
https://github.com/libimobiledevice 源代码项目
依赖关系
本文只分析到系统日志获取的功能,更高级的功能,如:关机、重启、截屏、文件系统等暂未涉及

openssl
https://www.openssl.org/
最新的git代码config配置变化,我们使用以前的常用版本https://www.openssl.org/source/old/1.0.2/
依次执行
./Configure
make
sudo make install
cd到/usr/local/
在include文件夹中找到 openssl目录保存备用
在lib文件夹中找到libcrypto.a和libssl.a保存备用
libplist
https://github.com/libimobiledevice/libplist.git
依次执行
./autogen.sh
make
sudo make install
cd到/usr/local/
在include文件夹中找到 plist 目录保存备用
在lib文件夹中找到 libplist.a 保存备用
libusbmuxd
https://github.com/libimobiledevice/libusbmuxd.git
依次执行
./autogen.sh
make
sudo make install
cd到/usr/local/
在include文件夹中找到 usbmuxd.h 和 usbmuxd-proto.h 文件保存备用
在lib文件夹中找到 libusbmuxd.a 保存备用
libimobiledevice
https://github.com/libimobiledevice/libimobiledevice.git
依次执行
./autogen.sh
make
sudo make install
cd到/usr/local/
在include文件夹中找到 libimobiledevice 目录保存备用
在lib文件夹中找到 libimobiledevice.a 保存备用
按照层级组织lib库,构建xcode工程

问题集合
1.ssl编译不通过
可能由于系统中存在冲突的ssl环境,可以清除、重启后重新安装
2.utils.c:307:9: warning: 'CLOCK_MONOTONIC' macro redefined [-Wmacro-redefined]#define CLOCK_MONOTONIC 1
CLOCK_MONOTONIC重复定义,直接注释掉即可
3.utils.c:309:12: error: static declaration of 'clock_gettime' follows non-static declaration
静态方法未定义,将方法前的static去掉
4.<plist/plist.h> file not found
plist 头文件无法索引到,改为 ”plist/plist.h”形式引用
5.<cstddef> file not found
C++头文件无法索引到,将项目中引用到libimobiledevice相关文件的 .m 改为 .mm
工程下载地址:https://github.com/one2zero/PrivateiOSDeviceConsole 感觉有用的尽管拿去吧。
网友评论
"_idevice_free", referenced from:
_main in main.o
帮看一下这个错误怎么处理
/Applications/Xcode.app/Contents/Developer/usr/bin/make all-recursive
Making all in src
CC ideviceinstaller-ideviceinstaller.o
ideviceinstaller.c:928:73: error: format specifies type 'long long' but the
argument has type 'ssize_t' (aka 'long') [-Werror,-Wformat]
...fprintf(stderr, "Error: wrote only %d of %" PRIi64 "\n", total, amount);
~~~ ^~~~~~
ideviceinstaller.c:910:20: error: comparison of integers of different signs:
'off_t' (aka 'long long') and 'zip_uint64_t' (aka 'unsigned long long')
[-Werror,-Wsign-compare]
while (zfsize < zs.size) {
~~~~~~ ^ ~~~~~~~
2 errors generated.
make[2]: *** [ideviceinstaller-ideviceinstaller.o] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
确定是在openssl的目录么
openssl
https://www.openssl.org/
最新的git代码config配置变化,我们使用以前的常用版本https://www.openssl.org/source/old/1.0.2/
依次执行
./Configure
make
sudo make install
cd到/usr/local/
在include文件夹中找到 openssl目录保存备用
在lib文件夹中找到libcrypto.a和libssl.a保存备用
./Configure
make
sudo make install