Skip to content

Commit

Permalink
v0.3.5 Bugfix/support ideviceinstaller (#44)
Browse files Browse the repository at this point in the history
* rm ideviceinstaller

* v0.3.5

* rm libdeviecmobile info checker
  • Loading branch information
zhaoye authored Nov 27, 2020
1 parent 182136a commit 546233a
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 76 deletions.
121 changes: 64 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
# Lyrebird iOS Plugin

[![Build Status](https://travis-ci.org/Meituan-Dianping/lyrebird-ios.svg?branch=master)](https://travis-ci.org/Meituan-Dianping/lyrebird-ios)
[![PyPI](https://img.shields.io/pypi/v/lyrebird-ios.svg)](https://pypi.python.org/pypi/lyrebird-ios)
![PyPI](https://img.shields.io/pypi/pyversions/lyrebird-ios.svg)
![GitHub](https://img.shields.io/github/license/meituan/lyrebird-ios.svg)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/25eaa2cd08a34cad966a271cf0c2f910)](https://www.codacy.com/manual/Lyrebird/lyrebird-ios?utm_source=github.com&utm_medium=referral&utm_content=Meituan-Dianping/lyrebird-ios&utm_campaign=Badge_Grade)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/25eaa2cd08a34cad966a271cf0c2f910)](https://www.codacy.com/manual/Lyrebird/lyrebird-ios?utm_source=github.com&utm_medium=referral&utm_content=Meituan-Dianping/lyrebird-ios&utm_campaign=Badge_Grade)

---

**[Lyrebird](https://github.com/Meituan-Dianping/lyrebird)**
是一个基于拦截以及模拟 HTTP/HTTPs网络请求的面向移动应用的插件化测试平台
是一个基于拦截以及模拟 HTTP/HTTPs 网络请求的面向移动应用的插件化测试平台

**iOS plugin是一个Lyrebird的插件,用于从iOS设备获取信息,如详细的设备信息、屏幕快照和应用信息。**
**iOS plugin 是一个 Lyrebird 的插件,用于从 iOS 设备获取信息,如详细的设备信息、屏幕快照和应用信息。**

## 快速开始

### 环境要求

* macOS
- macOS

* [Python >= 3.6](https://www.python.org/downloads/release/python-360/)
- [Python >= 3.6](https://www.python.org/downloads/release/python-360/)

* [libimobiledevice](https://github.com/libimobiledevice/libimobiledevice)
- [libimobiledevice](https://github.com/libimobiledevice/libimobiledevice)

* [Command Line Tools for Xcode](https://developer.apple.com/download/more/)
- [Command Line Tools for Xcode](https://developer.apple.com/download/more/)

### 环境准备

Expand All @@ -31,18 +33,20 @@

1. 通过 Homebrew 安装 [libimobiledevice](https://github.com/libimobiledevice/libimobiledevice)

```bash
brew install --HEAD libimobiledevice
brew link --overwrite libimobiledevice
sudo chmod -R 777 /var/db/lockdown/
```
```bash
brew install --HEAD libimobiledevice
brew install ideviceinstaller
brew link --overwrite libimobiledevice
sudo chmod -R 777 /var/db/lockdown/
```

1. 最终,测试第三方依赖是否正常工作

```bash
ideviceinfo
idevicescreenshot
```
```bash
ideviceinfo
idevicescreenshot
idevicesinstaller -l
```

### 安装

Expand All @@ -58,34 +62,33 @@ lyrebird

### 使用

使用时,通过USB线链接手机和电脑即可
使用时,通过 USB 线链接手机和电脑即可

![Home Page](./image/iOS.png)

* 查看已连接设备的详细信息

* 截取 iOS 设备屏幕快照
- 查看已连接设备的详细信息

* 查看已连接设备的应用信息
- 截取 iOS 设备屏幕快照

- 查看已连接设备的应用信息

----
---

## 开发者指南

### 开发者环境

* macOS
- macOS

* Python3.6及以上
- Python3.6 及以上

* NodeJS
- NodeJS

* vscode(推荐)
- vscode(推荐)

* Chrome(推荐)
- Chrome(推荐)

### 配置Lyrebird-ios工程
### 配置 Lyrebird-ios 工程

```bash
# clone 代码
Expand All @@ -109,6 +112,7 @@ code .
### 调试代码

#### Vscode debug 配置

```JSON
{
"version": "0.2.0",
Expand Down Expand Up @@ -142,17 +146,17 @@ code .

#### 后端代码

1. 激活python虚拟环境
1. 激活 python 虚拟环境

通过 ```source venv/bin/activate``` 激活虚拟环境
通过 `source venv/bin/activate` 激活虚拟环境

2. 通过Debug功能启动
2. 通过 Debug 功能启动

按照上面 debug配置中 python:Lyrebrid配置启动即可
按照上面 debug 配置中 python:Lyrebrid 配置启动即可

#### 前端代码

1. 启动node server
1. 启动 node server

```bash
# 进入前端目录
Expand All @@ -162,13 +166,14 @@ cd frontend
npm run serve
```

2. 通过Debug功能启动浏览器
2. 通过 Debug 功能启动浏览器

按照上面 debug配置中 vuejs: chrome 配置启动即可
按照上面 debug 配置中 vuejs: chrome 配置启动即可

> 注意: vscode 需要安装chrome debug插件
> 注意: vscode 需要安装 chrome debug 插件
3. build 前端项目

3. build前端项目
```bash
# 进入前端目录
cd frontend
Expand All @@ -178,36 +183,38 @@ npm run build
```

## 常见问题

#### libimobiledevice 无法使用,终端提示 - "Could not connect to lockdownd ...".
按照如下步骤重新安装 libimobiledevice,并留意安装过程中的错误提示。

1. 卸载libimobiledevice
按照如下步骤重新安装 libimobiledevice,并留意安装过程中的错误提示。

```
brew uninstall --ignore-dependencies libimobiledevice
```
1. 卸载 libimobiledevice

1. 安装libimobiledevice
```
brew uninstall --ignore-dependencies libimobiledevice
```

```
brew install --HEAD libimobiledevice
```
1. 安装 libimobiledevice

1. 若在安装libimobiledevice时出现了错误提示,如提示usbmuxd的版本不正确,使用如下命令解决依赖的版本问题
```
brew install --HEAD libimobiledevice
```

```
brew uninstall --ignore-dependencies usbmuxd
brew install --HEAD usbmuxd
brew unlink usbmuxd
brew link usbmuxd
```
1. 若在安装 libimobiledevice 时出现了错误提示,如提示 usbmuxd 的版本不正确,使用如下命令解决依赖的版本问题

1. 再次安装libimobiledevice
```
brew uninstall --ignore-dependencies usbmuxd
brew install --HEAD usbmuxd
brew unlink usbmuxd
brew link usbmuxd
```

```
brew install --HEAD libimobiledevice
```
1. 再次安装 libimobiledevice

```
brew install --HEAD libimobiledevice
```

#### 截取屏幕快照功能无法正常工作,提示 Could not start screenshot service!

在连接设备之前您必须确保开发者选项可用。通过 [stackoverflow](https://stackoverflow.com/questions/30736932/xcode-error-could-not-find-developer-disk-image) 获取更多解决帮助。
Binary file removed lyrebird_ios/bin/1.2.0/ideviceinstaller
Binary file not shown.
Binary file removed lyrebird_ios/bin/1.3.0/ideviceinstaller
Binary file not shown.
22 changes: 4 additions & 18 deletions lyrebird_ios/ios_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,14 @@

ios_driver = wda_helper.Helper()


def check_environment():
"""
检查用户环境,第三方依赖是否正确安装。
:return:
"""
global ideviceinstaller, idevice_id, idevicescreenshot, ideviceinfo

# Check libmobiledevice, action when unavailable : block
p = subprocess.run('brew info --json libimobiledevice', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
code, output, err_str = p.returncode, p.stdout.decode(), p.stderr.decode()
if err_str or code or not output:
raise LibmobiledeviceError(f'Get libmobiledevice info error: {err_str}')

try:
libimobiledevice_info = json.loads(output)
except Exception:
raise LibmobiledeviceError(f'Get unknown libmobiledevice info: {output}')

if not isinstance(libimobiledevice_info, list) and not len(libimobiledevice_info):
raise LibmobiledeviceError(f'Get unknown libmobiledevice info: {output}')

# Check idevice_id, action when unavailable : block
idevice_id_keywords = 'idevice_id'
idevice_id = SYSTEM_BIN/idevice_id_keywords
Expand All @@ -68,11 +55,8 @@ def check_environment():
env_err_msg = []

# Check ideviceinstaller, action when unavailable : warning
lib_version = libimobiledevice_info[0].get('versions', {}).get('stable')
lib_version = '1.2.0' if version.parse(lib_version) < version.parse('1.3.0') else '1.3.0'

ideviceinstaller_keywords = 'ideviceinstaller'
ideviceinstaller = Path(__file__).parent/'bin'/lib_version/ideviceinstaller_keywords
ideviceinstaller = SYSTEM_BIN/ideviceinstaller_keywords
err_msg = check_environment_item(ideviceinstaller_keywords, ideviceinstaller)
if err_msg:
env_err_msg.append(err_msg)
Expand All @@ -90,6 +74,7 @@ def check_environment():
if env_err_msg:
_log.error('iOS Plugin environment warning:\n' + '.\n'.join(env_err_msg))


def check_environment_item(command, path, sub_command=''):
if not Path(path).exists():
return f'Command `{command}` not found, check your libimobiledevice'
Expand All @@ -98,6 +83,7 @@ def check_environment_item(command, path, sub_command=''):
err_str = p.stderr.decode()
return f'Execute command `{command}` error: {err_str}' if err_str else ''


def read_plist(plist_path):
return plistlib.readPlist(plist_path)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name='lyrebird-ios',
version='0.3.4',
version='0.3.5',
packages=['lyrebird_ios'],
url='https://github.com/meituan/lyrebird-ios',
author='HBQA',
Expand Down

0 comments on commit 546233a

Please sign in to comment.