简体   繁体   中英

launching iOS App from Mac OS X console

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

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

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/

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) Debugging iOS app built from commandline

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.

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

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM