从 Mac OS X 控制台启动 iOS 应用程序 [英] launching iOS App from Mac OS X console

查看:32
本文介绍了从 Mac OS X 控制台启动 iOS 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了自动测试应用程序,我想从我的 Mac 上重复启动一个带有不同参数的 iOS 应用程序.为简单起见,我们假设它需要一个文件作为 argc,我有 100 个需要测试的文件.理论上,我只想重现 xcode build & 的行为.运行 - 在设备上运行,而不是越狱;该应用程序与硬件密切相关,因此仅靠模拟器是不够的.

in order to automate testing an application, I want to repeatedly launch an iOS app with different arguments to it's main function from my mac; for simplicity let's just say it takes a file as argc and I have 100 files that I need to test. In theory, all I'd want to reproduce is the behaviour of xcode build & run - on the device, not jailbroken; the app is closely tied to the hardware, so the simulator alone will not suffice.

有几个页面做了类似的事情,但没有一个使用该设备,也没有一个真正说明控制台上命令行的实际外观.

There are a couple of pages that do something similar, but none of them use the device, and none of them actually spell out how the command line on the console would actually look like.

1) http://blog.carbonfive.com/2011/04/06/running-xcode-4-unit-tests-from-the-command-line/

此页面设置最终在模拟器中运行的单元测试;他接着说

this page sets up a unit test that eventually runs in the simulator; he goes on to say that

单元测试构建目标的运行脚本"构建阶段只是运行 >${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests"

The "Run Script" build phase of a unit test build target just runs >"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests"

我检查了,但 RunPlatformUnitTests 和 RunUnitTests 都不是从 Xcode 4 执行的(我重命名了脚本以确保).

I checked that, but neither RunPlatformUnitTests nor RunUnitTests is executed from Xcode 4 (I renamed the scripts to make sure).

2) http://longweekendmobile.com/2011/04/17/xcode4-running-application-tests-from-the-command-line-in-ios/

此页面从 1) 左侧开始,但仅针对模拟器构建,并未指定应用程序的实际启动方式.它很好地描述了它是如何从命令行构建的.

this page picks up where 1) left but only builds for the simulator and doesn't specify how the app is actually launched. It describes well how it's build from command line though.

3) 调试从命令行构建的 iOS 应用

我在 Xcode 4 中看到的是构建阶段,它在签名和验证应用程序时停止.接下来我看到的是在设备上运行的 gdb 调试器.但是,我不知道如何访问调试服务器 - 我没有越狱我的 iPhone,所以我无法访问它上面的任何东西,既没有调试服务器也没有 IP 地址.

What I see in Xcode 4 is the build phase, which stops at signing and validating the application. The next thing I see is the gdb debugger that runs on the device. However, I don't know how to access debugserver - I didn't jailbrake my iPhone so I have no access to just about anything on it, neither debugserver nor the IP adress.

我可以验证的是,gdb 是从 xcode4/platforms/iPhoneOS.platform 调用的,因此远程调试器必须以某种方式将自身附加到某些东西...

What I can verify is that gdb is called from xcode4/platforms/iPhoneOS.platform so the remote debugger must attach itself to something, somehow ...

推荐答案

命令行远程GDB(或者只是上传到设备)可以用这个小工具,选择最接近你需要的fork,原作者不会再支持一下:https://github.com/ghughes/fruitstrap

For command line remote GDB (or just upload to device) you can use this little tool, choose the fork closest to what you need, the original author will not support it anymore: https://github.com/ghughes/fruitstrap

您可能无法按原样使用它(我不得不调整 gdb 参数以供使用),但这是一个好的开始.

You may not be able to use it as-is (I had to tweak the gdb parameters for my use) but its a good start.

您可以通过自动运行此脚本来进一步自动化操作

You can further automate things by automatically run this script

for i in $(system_profiler SPUSBDataType | grep "Serial Number: " | grep -Po "[A-Za-z0-9]{40,}$") ; do
    echo "Installing on: $i"
    #use fruitstrap with device $i
end

这将简单地检查所有 USB 端口并仅保留当前连接到 iOS 设备的端口并返回其 UDID.

this will simply check all USB port and keep only the ones that are currently connected to an iOS device and return its UDID.

从那里你应该能够为你的应用使用几个不同的参数来自动化测试.

From there you should be able to automate the testing with several different arguments for your app.

这篇关于从 Mac OS X 控制台启动 iOS 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆