How do I automatically run my iphone app after building it? - iphone

I'm using google unit testing code.
I'm building it quite nicely with xcodebuild on the command line. Now I want to run it (preferably on attached Device but simulator would also work) and catch all the feedback from the tests.
But I can't find out how to run it. Any ideas?

Jeff Haynie's iphonesim project on Github looks like it could work. I had trouble building 27812bb4b (make failed on a warning in nsprintf.m), but that may just be me using a pre-release OS and SDK. See also this related question.

If you followed the instructions from the Google page (creating the target, adding the test files to the target) and you have an iPhone SDK certificate (you need it to upload apps to the device) you can just change the Active SDK to your device (upper left corner combo in XCode)
If you don't have a certificate, you need to apply to the SDK program.

The only iPhone simulator and debugger I'm aware of comes with the iPhone SDK. In order to use the iPhone SDK you need to have an Intel-based mac with OS 10.5 Leopard installed, in which case you might as well be programming/compiling in XCode instead of using the command line.

There has to be some misunderstanding here. What exactly do you want to run from the command line? The test suite? If so, the test suite should be a separate target, so that all you have to do is build it, for example like this:
xcodebuild -target UnitTests -sdk iphonesimulator2.2.1 -configuration Debug
If you have the testing target configured correctly, it will run the RunIPhoneUnitTest.sh shipped with the Google Toolbox and the script will run all your tests.

Related

Jailbreak development using xcode

I have been looking around for learning how xcode can be used for jailbreak development.
I have Lion and jailbroken iPhone3G and xcode4.6 which doesnt support iPhone3G.
I have installed ldid but have no idea how to use it.
I have to make launch daemons, too, and attach them with my application. I have followed this tutorial for making a daemon but i got stuck in the setup for creating an open tool chain template in xcode. I followed every step but my xcode is not showing any template for open tool chain. Is it really required to have open tool chain template?
You're right. Xcode 4.6 doesn't support the iPhone 3G. Can you install an older version of Xcode? For example, Xcode 4.4 still supports the 3G.
Login to the Apple Developer Portal and download old versions here
You can choose to install the old version of Xcode in a different folder, so that it doesn't overwrite the new version (for example, install to /Developer-old/ or something).
Once you install the old Xcode version, you can navigate to the installation directory and look for the directory named:
iPhoneOS5.0.sdk
(or probably iPhoneOS5.1.sdk would work, too). Then, copy that entire folder into the new Xcode 4.6 installation directory. For example:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs
Afterwards, you should see this:
iPhoneOS5.0.sdk
iPhoneOS6.1.sdk
With the 5.0 SDK installed, you can now build apps for the iPhone 3G, using Xcode 4.6. You can also now uninstall Xcode 4.4 if you want. See more about this in this other question. The key is that you will be building your app for armv6 (only). Armv6 is the iPhone 3G's processor.
The second step is to turn off code-signing within Xcode. In your project settings, you set the provisioning profile to Don't Code Sign. You must modify an Xcode configuration file to allow you to do this.
Now you build the app in Xcode. When you're done, navigate to the directory on your Mac where the app has been built (where the MyAppName.app/ folder is). Then, you use ldid to fake code sign the app executable:
ldid -S MyAppName.app/MyAppName
Now, your app has a fake code signature that will allow it to run on a jailbroken phone.
Then, you use ssh, or scp, or something else to transfer it to your phone, where it should be installed under /Applications/.
You already have the best link on building iOS Launch Daemons. I'd stick with that tutorial. No, I don't have any open toolchain template in Xcode, either. I just use Chris' tutorial to see how to build a non-graphical daemon main program (not a UIApplication), copy it to my MyAppName.app folder, and create a com.mycompany.mydaemon.plist file that defines the Launch Daemon.
Once the plist is installed in /System/Library/LaunchDaemons/ on the phone, you can start it, without having to reboot the phone, with:
launchctl load -w /System/Library/LaunchDaemons/com.mycompany.mydaemon.plist
at the command line (on the phone). Or, just reboot the phone, and the daemon will start automatically.
Although I learned to do this before it was available, you can now look at iOSOpenDev if you'd like a more polished way of doing some of this stuff.
Yes. Xcode can be used for developing jailbreak-type projects. Use iOSOpenDev to set up Xcode and iOS SDK to allow jailbreak-type development.
iOSOpenDev comes with a set of templates, signs (with ldid) targets and creates Debian packages (packages are submitted to repos like ModMyI and BigBoss) during its build phase, in addition to installing packages directly to an iDevice with Cmd-Shift-I (build for profiling shortcut) for immediate testing, among other useful features for using Xcode to develop jailbreak-type projects.

How to install an ipa/app file into iPhone with command line?

I want to know how to install an ipa/app file into iPhone just using the command line?
The device maybe without jailbreak or jailbroken already.
I tried to use the command line: xcodebuild, but failed. I didn't find the parameter how to set the destination, maybe a real device, not a simulator.
What options do I have?
Three ways I know of:
These guys wrote a tool in Ruby to do it. It uses the Fruitstrap library which in turn uses one of Apple's private APIs, so this could possibly break in the future.
You can also just use Fruitstrap on its own, but then you need an .app directory, whereas the Transporter Chief tool I linked above supports both .app and .ipa deployments (as required in your answer).
In either case, you need to have XCode installed for it to work, but the device does not need to be jailbroken.
Thirdly, there is also a binary distribution for OS X of the libimobiledevice library, which enables Linux boxes to talk to iOS devices. This has a few different tools, one of which can install valid signed IPAs to the device using this syntax:
ideviceinstaller -i myapp.ipa
The advantage of this method is that it does not need XCode or even iTunes.
With the new Apple Configurator 2 application, you can Install Automation Tools... from the menu. This will add support for the command-line tool "cfgutil".
cfgutil allows you to install ipa's from the command-line using cfgutil install-app <AbsolutePathToIpa>. We use it on our build server to automatically update the device with the latest build.
I've just gathered in a single post (Gist) how to achieve this, using
1.- Mattt's library Shenzhen
2.- Phonegap's library ios-deploy
Read here:
How to generate and install an IPA file
I've tried libimobiledevice-macosx. works fine on iPhone 5. iOS version 6.1.4.
I was able to install app and see log output like in xcode :) Thank you!

xcodebuild install path?

I am developing an iphone app using xcode. I would like to automate the "build and run" process, and so want to know if there is any way to install the built app on simulator or device.
There is xcodebuild install command but i don't know how to set the installation directory DSTROOT to simulator/device. Please help me there.
I have looked through many forums where people suggest just to use xcode GUI to do the stuff, and I do that too, but I would really like to know the command-line way.
Thanks
All you need to do is copy the built .app from wherever XCode puts it to ~/Library/Application Support/iPhone Simulator/User/Applications/[somefolder]/, with a file named [somefolder].sb (alongside the folder, not in it) containing the following:
(version 1)
(debug deny)
(allow default)
Then launch /Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator. And select your App. Without Jailbreaking it's NOT possible to install it from outside the GUI.
The install build action for Xcode will only copy the built product to the install path specified in the xcode project.
This is used for frameworks and libraries that need installing after being built so that other apps can link against them from a common location.
I don't think you'll be able to use this build action to automate the Build and Run process - that is going to have to be done manually by each developer. There is no way to push apps onto a device without using Xcode, iTunes or the iPhone Configuration utility. As for the Simulator, it's as woodleader says. But for the device, without jailbreaking and writing your own code, you can't do this.
What you can do is use xcodebuild to generate daily/nightly builds for continuous integration. You can write a script that checks out the source form version control, runs xcodebuild and puts the built product in an easy to reach location. The installtion onto devices will still need to be done manually however.

Building and code signing an iPhone Application from the command line

I want to make my iPhone Apps in Emacs now, so without using Xcode at all.
How can I build and codesign my app from the command line (even through SSH)? I can't use xcodebuild as there is no Xcode project. Are there any tutorials which cover this? I want to compile them with GCC, and as soon as Developer Tools 4.0 come out, I want to compile them with LLVM.
Can anyone help me? Thanks.
Is it also possible to debug it on the device without Xcode?
You could start with running a build through Xcode and then having a look at the build log. It contains all the commands and respective parameters used to build your project.
Then is should "just" be a matter of creating a make file using the same commands.

How can I deploy an app to my iPhone from the command line?

I can already build an app with a distribution profile via the command line
xcodebuild -configuration Distribution -sdk iphoneos3.0 clean build
However, I'd like to go one step further and install the app to the connected iPhone and execute it ( as if I'd pressed Build and Run in XCode ).
The final command listed in the build commands window ( cmd+shift+B ) is CodeSign, which as far as I know just signs the code and nothing else. So I'm not sure what command ( if any is available ) I can run from the command line to install and run the app on the iPhone.
I'm running the official SDK, not a jailbroken phone.
If you have a post build script you should be able to install it and run it using a script. If you're jailbroken you should be able to use SCP and then execute it directly.
There may be an AppleScript or automator way of solving the problem as well.
I've written a blog entry on how to install apps on a connected iPad / iPhone without using Xcode or iTunes. This method does NOT require JailBreak - any iOS device will work. Only works on the Mac though.
This method allows you to run a Terminal command to install an iPA file.
http://pervasivecode.blogspot.co.uk/2012/06/install-ios-app-ipa-file-without-xcode.html