diff --git a/README.md b/README.md index 9c28878..04dcb75 100644 --- a/README.md +++ b/README.md @@ -105,52 +105,11 @@ ADB 调试能力,可通过 WiFi 或网络连接设备,实现灵活的远程 ## iPhone 环境准备 -### 1. Python 环境 +如果你使用的是 iPhone 设备,请参考专门的 iOS 配置文档: -建议使用 Python 3.10 及以上版本。 +📱 [iOS 环境配置指南](docs/ios_setup/ios_setup.md) -### 2. 设置 WebDriverAgent - -WebDriverAgent 是 iOS 自动化的核心组件,需要在 iOS 设备上运行。 - -注意:需要提前安装好Xcode、并注册好苹果开发者账号(不需要付费) - -#### 1. 克隆 WebDriverAgent - -```bash - -git clone https://github.com/appium/WebDriverAgent.git -cd WebDriverAgent -``` -在 Xcode 中打开WebDriverAgent.xcodeproj - -#### 2. 设置 Signing & Capabilities - -![设置签名](resources/setup-xcode-wda.png) - -把Bundle ID改成 YOUR_NAME.WebDriverAgentRunner。 - -#### 3. 开始UI测试 - -需要在Finder勾选过“在WiFi中显示这台iPhone”,且Mac与iPhone处于同一WiFi网络之下,可以不用连接数据线,即可在设备中选择到。 - -**注意:** 不建议插数据线运行,因为插数据线还必须要同时运行iproxy才可以把端口映射出来,不及直接WiFi运行稳定。 - -先从项目Target选择WebDriverAgentRunner,然后再选择你的设备。 - -![选择设备](resources/select-your-iphone-device.png) - -选好后,长按"▶️"运行按钮选择“Test”后开始编译并部署到你的iPhone上。 - -![信任设备](resources/start-wda-testing.png) - -这时需要你在iPhone上输入解锁密码,在设置 -> 通用 -> VPN与设备管理 中信任开发者App,还需要在 设置 -> 开发者 中,打开UI自动化设置。 - - - -![信任设备](resources/trust-dev-app.jpg) - -![启用UI自动化](resources/enable-ui-automation.jpg) +该文档详细介绍了如何配置 WebDriverAgent 和 iPhone 设备,以便在 iOS 上使用 AutoGLM。 ## 部署准备工作 diff --git a/docs/ios_setup/ios_setup.md b/docs/ios_setup/ios_setup.md new file mode 100644 index 0000000..a2b22fe --- /dev/null +++ b/docs/ios_setup/ios_setup.md @@ -0,0 +1,134 @@ +# iOS 环境配置指南 + +本文档介绍如何为 Open-AutoGLM 配置 iOS 设备环境。 + +## 环境要求 + +- macOS 操作系统 +- Xcode(最新版本,在App store中下载) +- 苹果开发者账号(免费账号即可,无需付费) +- iOS 设备(iPhone/iPad) +- USB 数据线或同一 WiFi 网络 + + +## WebDriverAgent 配置 + +WebDriverAgent 是 iOS 自动化的核心组件,需要在 iOS 设备上运行。 + +### 1. 克隆 WebDriverAgent + +```bash +git clone https://github.com/appium/WebDriverAgent.git +cd WebDriverAgent +``` + +直接点击`WebDriverAgent.xcodeproj`即可使用Xcode打开。 + +### 2. 设置 Signing & Capabilities + +1. 在 Xcode 中选中 `WebDriverAgent`,出现General、Signing&Capabilities等选项。 +2. 进入 `Signing & Capabilities` 选项卡 +3. 勾选 `Automatically manage signing`。在Team中选择自己的开发者账号 +4. 将 Bundle ID 改为唯一标识符,例如:`com.yourname.WebDriverAgentRunner` +![设置签名1](resources/ios0_WebDriverAgent0.png) + +5. TARGETS中,建议将WebDriverAgentLib、WebDriverAgentRunner、IntegrationApp的`Signing & Capabilities` 都按照相同方式设置。 +![设置签名1](resources/ios0_WebDriverAgent1.png) + +### 3. 测试XCode的GUI模式和UI自动化设置 + +建议先测试GUI模式能否成功安装WebDriverAgent,再进行后续步骤。 +Mac和iPhone有USB和WiFi两种连接方式,建议通过USB方式,成功率更高。 + +#### 通过 WiFi 连接 + +需要满足以下条件: +1. 通过USB连接。在Finder中选中连接的IPhone,在“通用”中勾选"在 WiFi 中显示这台 iPhone" +2. Mac 与 iPhone 处于同一 WiFi 网络之下 + +#### 具体步骤 +1. 从项目 Target 选择 `WebDriverAgentRunner` +2. 选择你的设备 + +![选择设备](resources/select-your-iphone-device.png) + +3. 长按"▶️"运行按钮,选择 "Test" 后开始编译并部署到你的 iPhone 上 + +![开始测试](resources/start-wda-testing.png) + +部署成功的标志:1. XCode没有报错。2. 你可以在iPhone上找到名为WebDriverAgentRunner的App + +#### 设备信任配置 + +首次运行时,需要在 iPhone 上完成以下设置,然后重新编译和部署: + +1. **输入解锁密码** +2. **信任开发者应用** + - 进入:设置 → 通用 → VPN与设备管理 + - 在“开发者 App”中选择对应开发者 + - 点击信任“XXX” + + ![信任设备](resources/trust-dev-app.jpg) + +3. **启用 UI 自动化** + - 进入:设置 → 开发者 + - 打开 UI 自动化设置 + + ![启用UI自动化](resources/enable-ui-automation.jpg) + +### 4. XCode命令行模式部署 + +1.安装libimobiledevice,用于与 iPhone / iPad 建立连接与通信。 + +``` +brew install libimobiledevice +# 设备检查 +idevice_id -ln +``` +2.使用xcodebuild安装WebAgent。命令行也需要进行“设备信任配置”,参考GUI模式下的方法。 + +``` +cd WebDriverAgent + +xcodebuild -project WebDriverAgent.xcodeproj \ + -scheme WebDriverAgentRunner \ + -destination 'platform=iOS,name=YOUR_PHONE_NAME' \ + test +``` +这里,YOUR_PHONE_NAME可以在xcode的GUI中看到。 +WebDriverAgent 成功运行后,会在 Xcode 控制台输出类似以下信息: + +``` +ServerURLHere->http://[设备IP]:8100<-ServerURLHere +``` + +同时,观察到手机上安装好了WebDriverAgentRunner,屏幕显示Automation Running字样。 +其中,**http://[设备IP]:8100**为WiFi所需的WDA_URL。 + +## 使用 AutoGLM + +以上配置完成后,先打开一个新终端,在后台建立端口映射(使用WiFi连接则不需要): + +```bash + iproxy 8100 8100 +``` + +之后,打开一个新终端,通过以下命令使用AutoGLM(WiFi则使用上述获得的WDA_URL): + +```bash +python ios.py --base-url "YOUR_BASE_URL" \ + --model "autoglm-phone" \ + --api-key "YOUR_API_KEY" \ + --wda-url http://localhost:8100 \ + "TASK" +``` + +## 参考资源 + +- [WebDriverAgent 官方仓库](https://github.com/appium/WebDriverAgent) +- [PR141](https://github.com/zai-org/Open-AutoGLM/pull/141) +- [Gekowa提供的ios方案](https://github.com/gekowa/Open-AutoGLM/tree/ios-support) + +--- + +如有其他问题,请参考主项目 README 或提交 Issue。 diff --git a/docs/ios_setup/resources/enable-ui-automation.jpg b/docs/ios_setup/resources/enable-ui-automation.jpg new file mode 100644 index 0000000..dccd6c0 Binary files /dev/null and b/docs/ios_setup/resources/enable-ui-automation.jpg differ diff --git a/docs/ios_setup/resources/ios0_WebDriverAgent0.png b/docs/ios_setup/resources/ios0_WebDriverAgent0.png new file mode 100644 index 0000000..b9f2004 Binary files /dev/null and b/docs/ios_setup/resources/ios0_WebDriverAgent0.png differ diff --git a/docs/ios_setup/resources/ios0_WebDriverAgent1.png b/docs/ios_setup/resources/ios0_WebDriverAgent1.png new file mode 100644 index 0000000..f62274c Binary files /dev/null and b/docs/ios_setup/resources/ios0_WebDriverAgent1.png differ diff --git a/docs/ios_setup/resources/select-your-iphone-device.png b/docs/ios_setup/resources/select-your-iphone-device.png new file mode 100644 index 0000000..259042e Binary files /dev/null and b/docs/ios_setup/resources/select-your-iphone-device.png differ diff --git a/docs/ios_setup/resources/setup-xcode-wda.png b/docs/ios_setup/resources/setup-xcode-wda.png new file mode 100644 index 0000000..0635731 Binary files /dev/null and b/docs/ios_setup/resources/setup-xcode-wda.png differ diff --git a/docs/ios_setup/resources/start-wda-testing.png b/docs/ios_setup/resources/start-wda-testing.png new file mode 100644 index 0000000..585c9aa Binary files /dev/null and b/docs/ios_setup/resources/start-wda-testing.png differ diff --git a/docs/ios_setup/resources/trust-dev-app.jpg b/docs/ios_setup/resources/trust-dev-app.jpg new file mode 100644 index 0000000..00525c1 Binary files /dev/null and b/docs/ios_setup/resources/trust-dev-app.jpg differ