How to run UIAutomation script from command line to Simulator - iphone

I have automated my iOS application using UIAutomation, To run this I launch iOS Instruments and run the script. If Same automation script I want to run to the device I use the below command which works as desired
instruments -w -t /Developer/Platforms/iPhoneOS.platform/Developer/Library/Instruments/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate myapp -e UIASCRIPT regression.js
But how do I run this from the command line to iOS Simulator ?
Please suggest.
Thanks
Sougata

If you don't supply the '-w' argument and build your app for the simulator sdk it should launch on the simulator.

In Xcode 6.0.1, running with the -w switch and passing in the symbolic name of the simulator appears to now be required (at least that's the only way I got it to work, and I've had others verify and point me to this solution).
See my answer from another post that has an explicit example.
You can also find a bash shell script that will handle invocation for you, automating the resolution of UDID and GUIDs in your simulator app paths.

Related

Command line ios app upload with Xcode 6

We have been using the answer provided here (How to upload an iOS app to the app store via command line) by Tomer Shiri to automate the uploading of our apps to the iTunes Connect using a script. This has been worked fine with Xcode 5.X but now we have installed Xcode 6 this fails when run.
We believe the script we have made is falling over on the line that contains the xcrun command with the error of:
users-mac-mini:~ user$ sh /Users/user/Desktop/Master\ Upload\ Script.sh
sh: create.sh: No such file or directory
error: Unknown application extension '.' - expected '.app' or '.ipa'
Does anyone know if the xcrun command has changed in Xcode 6? and if so what would be the equivalent command that incorporates any changes?
Thanks
James
EDIT: as a side thought I have seen a few comments around the internet that suggest that apple has confirmed that this is an undocumented tool. With that in mind, is anyone with decompiling\ disassembly skills able and willing to pull this apart and find a list of the CLI options for the xcode 6 version of the xcrun binary?

Install .app file in simulator from the command line

How can I install a .app file in the simulator from the command line. Or do I need to install it from a .ipa file and how do I do that?
To run the app in the simulator you need a third party library like waxsim https://github.com/square/waxsim
You can setup their KIF library for acceptance tests
Then you can do a command line build and run it like this...
waxsim -f "ipad" "${MY_PATH}/MyApp.app" > $OUT_FILE 2>&1
Another option is to use the Frank libraries http://blog.thepete.net/blog/2012/06/24/writing-your-first-frank-test/ These are really easy to install and have a built in way to launch the simulator and run tests!

How to show the xcodebuild command line from xcode?

I'm trying to build a working simulator build from xcodebuild. Compilation works but the final product won't run on the simulator when installed via WaxSim. If I build through the Xcode GUI then the final product installs without issue from WaxSim.
My question is, how can I see the exact xcodebuild command line that xcode is using to build a working simulator build. I just need to copy that into my shell script but it's proving elusive. I did a find in the build logs from xcode but there's no mention of xcodebuild there.
You can't. Xcode itself doesn't invoke xcodebuild during the build process. This post has more information on executing xcodebuild to build for the simulator.

Deploying iOS apps to /Applications from XCode via build phase script? (Jailbroken)

I'm developing a Cydia app. It's been in development for awhile, and I've never had any problems until recently, when I resumed development after a few months. There are a couple of things that have changed since the last time I worked on it:
Upgraded to Lion
Moved to Xcode 4
Updated to 4.3.5 on my iPad, iPhone to 5.0
From the research I've done, I've come to the conclusion that there was something "unusual" about my old setup. I've discovered that provisioned apps get put in the "sandboxed directory" /private/var/mobile/Applications, and system apps that get read access to the entire filesystem go in /Applications. I guess from using updated tools and Lion, I broke whatever was giving me system-wide read privileges. So, I need information on how to get Xcode to deploy directly to the non-sandboxed system directory.
There are some caveats though. I don't want to have to use an installer, I want Xcode to do it automatically after Build and Run. I also want to be able to have the debugger attached so I can view the console.
Can anyone with experience in this teach me how to use Build Phase Scripts to do necessary magic to take the signed binary and deploy it automatically after each build? I'd imagine this is indeed possible, because console output is such a valuable tool, that it would be too difficult to develop apps like Cydia itself.
Thank you for your help!
The general consensus among the community is that this isn't desirable. A build system like Theos coupled with on device GDB and either a syslog package or deviceconsole is what many are using.
I added a script as custom build phase. The script signs the app, create a package, copy it to the phone and install it.
The Build Phase is "Run a Script" with /bin/sh and I added "${PROJECT_DIR}/MyApp/install.sh"
The scripts (very basic - no error handling) is below (replace with appropriate values) :
(LatestBuild is a link to the build directory)
(ldid is installed with iosopendev project)
cd $HOME/Projects/iPhone/MyProject/MyApp
cp -r ../LatestBuild/MyApp.app com.test.MyApp/Applications/
ldid -S com.test.MyApp/Applications/MyApp.app/MyApp
rm com.test.MyApp.deb 2>&1
/opt/local/bin/dpkg-deb -b com.test.MyApp
scp com.test.MyApp.deb root#192.168.0.10:/var/root
ssh root#192.168.0.10 "dpkg -r com.test.MyApp"
ssh root#192.168.0.10 "dpkg -i com.test.MyApp.deb"
ssh root#192.168.0.10 "killall -9 MyApp"
#ssh root#192.168.0.10 "killall -HUP SpringBoard"
cd -
It can be improved a lot - but it just works for my needs
I'm not particuralry well knowledgable about xcode but like most IDE's im assuming in one shape or another that you can have it run a post build script if you can figure out what that is its as simple as an scp command to upload from there you can use ldid -S nameofapp in the dir that the app is uploaded to.
You can if you want allow your app to reside in /Applications though upgrading to 4.3.5 most likely forces you on a tethered Jailbreak I'm not aware of an untethered JB for 4.3.5 so thats a hassle if you wind up having to reboot.
As far as debuggers give gdb(you can get it from cydia) a go its really useful :). What Id do is just have xcode run a post build script to use scp to upload to your device then sign it manually with ldid thats the easiest way i can think of unless you have access to a developer idevice.
Give me a few minutes Ill write a script and try to describe how it works I need one anyone since i finally got a mostly working open toolchain. :)
A simple upload script
#!/bin/bash
scp -r $1 $2#$3:$4
$1 is lets say your app folder ill use my dpatcher as an example
$2 is user name either mobile or root(if you upload as root you need to chmod permissions to 755)
$3 is your idevices local ip(ie your routers ip for it)
you can find your ip with sbsettings or by going to settings tap the blue arrow next to your ap and it will tell you.
$4 is where you want it to be most likely /Applications or /var/mobile/Applications
i named it upload.sh but you can name it anything
An example
upload.sh dpatcher.app mobile#192.168.1.65 /Applications
Then all you do is ssh in and sign it with ldid -S nameofapp
If you want to upload single files remove -r as thats for recursive uploads(ie folders)
the reason that you must use scp or sftp for uploading files is that normal ftp AFAIK is not supported with out the use of 3rd party apps.
I'm not sure how to integrate with Xcode I do every thing with either vi, emacs or nano(and I don't own a mac).

Is there a quick way to build & install to iPhone (from Xcode) without starting the app?

In Xcode, I can use CMD-R to run (or CMD-Y to debug), and my app will compile, install on the phone & start-up. (I've already prepped my phone & Xcode so this part works as expected.)
What I'd LIKE to do is type CMD-<something else> and have my program compile & install on the phone, but NOT start-up.
I realize that I can just CMD-B to build, then go through some rigamarole to deploy, but I'm hoping one of you smart-folk can tell me the lazy-man's shortcut for all of this.
Hey Olie, I haven't tried this because I don't have an iPhone to deploy to at the moment, but this /should/ work:
You can create a script which runs xcodebuild in your current project directory and give it the install target. Assuming you're going to want to debug at sometime, use the Debug configuration, otherwise use release. Then bind the script to some command key in the Xcode preferences and you should be on your way. To launch xcodebuild with debug you would do something like:
xcodebuild install -configuration Debug
If you have more than one target in your project you will have to specify that to xcodebuild as well:
xcodebuild install -target iPhoneApp -configuration Debug
You could also create a configuration specific to this scenario in your projects and pass that to xcodebuild and you should be able to script this in your favorite supported language (i.e., AppleScript, python, ruby, etc.).
HTH
I had the same question.
I ended up using the XCode Organizer. Select your current device. Summary Tab. "+" Applications..then select the one you just built (under /build/[debug|release]-iphoneos/.app
This does the install very easily.
Have you looked into using Automator? Here's a good write up on how to automate XCode to build and what not.
To build (exact flags documented under "man xcodebuild", install xcode's command line tools): xcodebuild build -sdk iphoneos6.0 workspace/project, targets, configs and/or scheme flags
To install (grab from github here then simply make and run): path/to/fruitstrap --id device-uuid-to-install-on --bundle path/to/ios.app