Reset iOS app from commandline - ios

I'm building a tool for building an iOS app and running UIAutomation on it. So far I've been targeting the iOS Simulator and I've run into a hiccup moving to running on real devices.
I have a feature where the tool reinstalls the app between each test, so that it always runs from an uninitialized and known state, which currently uses xcrun simctl uninstall and obviously doesn't work for real devices. I'm looking for something similar for real iOS devices.
Another working solution would be to reset the app through some nifty command.
I'm not interested in any UI based solutions, it has to run from a commandline.

iDeviceInstaller supports uninstalling/installing on real devices.
Uninstall:
/usr/local/bin/ideviceinstaller -U <app_bundleID> -u <device_UDID>
Install:
/usr/local/bin/ideviceinstaller -i <pathToIPA> -u <device_UDID>

We wrote an automation bridge in Illuminator that should allow you to send arbitrary commands to your application (in both the simulator and on real hardware).
It is accessed via the command line through a ruby script.

Related

Using Frida on XCode Simulator

Does anyone has experience with setting up Frida to work with XCode Simulator? I have been searching online but this is the closest thing I've got (https://programmersought.com/article/54464074345/)
However, when I compile and run the app on simulator, I did not see what was described in "quick smoke test". Any help is very appreciated !
As iOS simulator is essentially running apps on your native mac OS host, you can interacts with apps directly as if they are running on your machine.
In a nutshell:
Don't use -U argument as iOS simulator is not a USB device
frida-ps should give you a list of running processes, including the apps running on the simulator.
The rest of the APIs should work in the same way they do for mac OS host.

How can I run ios App on real device via OSX shell command not using instruments?

I want to start ios App on real-ios-device in OSX - shellcommand.
How can I do this not using instruments?
for example. .. $> runIosApp -u 821381u2adsu3jakd test.CalendarApp.
Phonegap made a set of tools to do this. You can find information on how to use it here: https://github.com/phonegap/ios-deploy

Reading qDebug output of Apps on ios devices from command line

I am currently working on automated testing of Qt-Applications on devices running iOS. So far I am able to install and run these Applications fine, but I am unable to read their output. As far as I understood, reading this issue, Qt uses the gdb server to deliver the output of std::out and std::err to the Qt Creator but I can not get my head around on how to use this information. Besides the bundle identifier, I am given the .ipa-file of the application only. I have access to the applications code but I must not change it.
I use the libmobiledevice libraries to handle all tasks like connection, installation and execution of and on the device.
To summarize: I want to read the debug output of a Qt-written application displayed on my console, like it would be in the "Application output" window of my Creator.
I found a way using the imobiledevice libraries. By calling Idevicedebug -u <uuid> run de.foo.app I was able to execute the application. The qDebug output was prompted to std::out.
As the app crashed when started with a locked screen, I had to check for the display being idle by examining the output of idevicediagnostics ioreg IOPower first.
Now, half a year later, I found a solution that worked both elegant and stable.
I installed the ios-deploy tool using node:
npm install -g ios-deploy
Using this, I was able to install the app and listen to it's output via:
ios-deploy --debug --bundle path/to/my.app
I recieved the full qDebug, std::out and std::err output perfectly fine.
To uninstall the app, I simply added the -9 or --uninstall_only option:
ios-deploy --debug --bundle path/to/my.app --uninstall_only
Using this solution the app could be started reliably, without crashing with a locked screen

How can i automate 'Settings' app in real iOS devices?

I tried with Appium, UI Automation and Monkey Talk to automate native app automation for real iOS device. Mentioned tools are not supporting real iOS native app automation.
Is there a (freeware) tool that automates native apps of real iOS devices?
You can try the following in your Terminal:
instruments -v -w YOUR_DEVICE_ID -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/Applications/Preferences.app -e UIASCRIPT /Users/mytests/Documents/xCode/Shell-Script/YourTestScript-App.js
The above command is a 1 liner.
But you need to write your own test script called YourTestScript-App.js

Remove iOS app from command line

So we're building this iOS application. We have performance tests that are automatically run by Jenkins. Of course these tests must be run on the device.
Right now we have a lot of trouble with some tests, and I suspect that they don't clean up after themselves, leaving the app's Documents folder in an uncertain state. Obviously I can fix the cleanup, but this will take a huge time.
I'd love to be able to just delete the app from the device before running the tests. Is there any way we can do this via xcodebuild or any other automatable tool. Could be even applescript or a non-official tool. The only rule is that we may not jailbreak the device.
One multi-platform option is libimobiledevice and the ideviceinstaller utility. It runs on Linux, Mac and Windows and even supports iOS 9.
As noted in the library webpage, it does not depend on jailbreak.
To delete an app do:
ideviceinstaller -uninstall com.somecompany.someapp

Resources