美文网首页ToolsMac开发Mac开发云集
Mac应用获取iOS设备运行Log

Mac应用获取iOS设备运行Log

作者: 见闻无限 | 来源:发表于2017-03-29 17:49 被阅读371次

问题引入

iOS自动化测试或者性能测试过程中,有不少场景是需要检测设备的日志信息。
甚至还需要提取其中的业务日志进行进一步分析。
那么就需要一个工具来摆脱手动拷贝日志的糟糕情况。

可行性分析

Xcode-Windows-Device 可以看到当前连接设备的运行日志
iTools、PP助手等第三方程序可以获取当前连接设备的运行日志
开源项目
https://github.com/benvium/libimobiledevice-macosx 可执行方案
https://github.com/libimobiledevice 源代码项目

依赖关系

本文只分析到系统日志获取的功能,更高级的功能,如:关机、重启、截屏、文件系统等暂未涉及

1.png

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工程

2.png

问题集合

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 感觉有用的尽管拿去吧。

相关文章

网友评论

  • 景彧:Undefined symbols for architecture x86_64:
    "_idevice_free", referenced from:
    _main in main.o

    帮看一下这个错误怎么处理
    景彧:上面的这个错误查出来了,是没有把那些静态库添加到工程中。
  • 景彧:Mac:ideviceinstaller Apple$ make
    /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
    景彧:@见闻无限 不是的,就是在git下来的文件夹目录下
    见闻无限:编译ssl的时候 怎么会有** [ideviceinstaller-ideviceinstaller.o] 之类的文件呢?
    见闻无限:Mac:ideviceinstaller Apple$ make
    确定是在openssl的目录么
  • 景彧:楼主你好,你能说一下那个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保存备用
    见闻无限:@i_蓝天 没有参数,代码目录里面应该有这个文件的
    景彧:@见闻无限 ./Configure 这个命令后面试没有参数的吗?
    见闻无限:哪个环节? 步骤很简单啊 ,代码clone下来后,cd到代码目录,依次执行:
    ./Configure
    make
    sudo make install
  • ZhongXi:您好,之前我也研究过libimobiledevice,当时就想写一个Mac端很直观的可以看到手机的log,但是不知道怎筛选指定进程log的输出.....
    见闻无限:@ZhongXi 啥意思呢?这个已经是手机进程的log了 如果你是说想要知道手机哪个app的log,那就太简单了啊 每个app打出来的log 都是带程序的buildname的 直接过滤就可以了

本文标题:Mac应用获取iOS设备运行Log

本文链接:https://www.haomeiwen.com/subject/iikyottx.html