Automated "Build and Run" Process

Hey everyone,

I’m setting up an Automator script for our iPhone project which we would like to have build our Unity project, and then install the resulting App to the device automatically. The reason for this is that we would like to run the script overnight so that when we come in the next day, anyone can pick up the device and see the progress on the application.

So far, I’ve been able to get Unity to build the project automatically through the command line tools and an associated editor script, like so:

Command Line

open -a Unity --args -executeMethod AutomatedBuild.PerformIOSBuild -quit

Editor Method

static void PerformIOSBuild()
{
	string[] scenes = {"Assets/Scenes/TitleScreen.unity", "Assets/Scenes/Level1.unity"};
		
	BuildPipeline.BuildPlayer(scenes, "Builds/iOS", BuildTarget.iPhone, 
		                       BuildOptions.Development  BuildOptions.AllowDebugging);
}

I then looked into building and running the XCode project. It is possible to build the project using the “xcodebuild” command (or the associated Automator command), but I couldn’t find a way to INSTALL the app to the device with xcode on the command line. (if anyone knows how to do this, I would love to hear)

So, with xcodebuild failing to install to the device for me, I realized that Unity seems to do the whole “create xcode project > compile through xcode > run on device” process automatically, so I was wondering if there is something else I can include in my PerformIOSBuild() method to make this happen, or if there is some other piece to this puzzle that I am missing.

Thanks!

1 Like

Hi,
we are using AppleScript to launch Unity iOS app on device using Xcode. If I remember correctly “install” step isn’t available as separate action, just as part of “debug” action.

If I recall right, the buildoptions flag BuildOptions.AutoRunPlayer is what “build run” in the editor does (while showbuilt player would be the normal “just build”) which should do it all for you.

Also, unless my mind is overworked, you are trashing the build flag there by using instead of | or +, aren’t you?

1 Like

Haha, I think you are right about the build flags. I had tried the AutoRunPlayer build option, but considering that I can’t keep my and | separated, I’ll give it another shot to see if that works. :slight_smile:

Also, thanks for the Applescript lead. I was hoping I could do it all with Automator, but I guess I should learn Applescript anyway.

Hey, just wanted to check back in over here. I’m making some good progress and will likely write a tutorial on this, but I’ve got one more roadblock to overcome or run into. :slight_smile:

I’ve got a shell script all set up to make the build directory, run Unity via the command line, build in xcode, and copy to the device, and this script works fine if I just run it via the terminal.

I’ve set it up to be a daily periodic script that is run by the system. My problem now is that when the computer wakes up in the morning, it runs the scripts in the background when the login screen is up. This is the behavior I’m hoping for because if I’ve got to log in to run the scripts, I might as well just do the process manually. Of course, an issue might be that Unity can only be run when you are logged in. Can anyone confirm/deny that this is the case?

Don’t know if this is helpful, but I receive a crash file for the automated build in the console. Here is a snippet of it:

Process:         Unity [6239]
Path:            /Applications/Unity/Unity.app/Contents/MacOS/Unity
Identifier:      Unity
Version:         ??? (???)
Code Type:       X86 (Native)
Parent Process:  sh [6236]

Date/Time:       2011-03-11 08:58:38.798 -0800
OS Version:      Mac OS X 10.6.6 (10J567)
Report Version:  6
Sleep/Wake UUID: 28398996-AFBE-47E0-894B-7D36D8A6DFB0

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000000
Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
0   com.apple.CoreFoundation      	0x931e7363 CFDictionaryGetValue + 83
1   com.unity3d.UnityEditor3.x    	0x00020715 ScreenManagerOSX::GetCurrentResolution() const + 85
2   com.unity3d.UnityEditor3.x    	0x00020834 ScreenManagerOSX::ScreenManagerOSX() + 100
3   com.unity3d.UnityEditor3.x    	0x000113a7 InitScreenManager() + 103
4   com.unity3d.UnityEditor3.x    	0x00034885 __static_initialization_and_destruction_0(int, int) + 261
5   [Bundle]                      	0x08660cf3 0x8566000 + 1027315
6   [Bundle]                      	0x08660d6d 0x8566000 + 1027437
7   [Bundle]                      	0x08660dbb 0x8566000 + 1027515
8   [Bundle]                      	0x086182fc O6DAU3KOHT3E8 + 300840
9   [Bundle]                      	0x085cdd34 22L2UF7SCRIR0 + 418360
10  [Bundle]                      	0x085e38e3 O6DAU3KOHT3E8 + 85263
11  [Bundle]                      	0x0861c64b IL_SC_D_PPC + 353
12  [Unknown Bundle]              	0x04a1a67d EntryPoint + 105395
13  [Unknown Bundle]              	0x04a01910 EntryPoint + 3654
14  [Unknown Bundle]              	0x04a00b68 EntryPoint + 158
15  ???                           	0x015380c5 0 + 22249669
16  ???                           	0x01537f57 0 + 22249303
17  com.unity3d.UnityEditor3.x    	0x0003c15d _start + 131
18  com.unity3d.UnityEditor3.x    	0x0003c0d9 start + 41

Hi,

Did you ever end up writing the tutorial? Also, I’m trying to perform a simliar deployment process.

  1. shell script that does an xcode build
  2. deploy internal build file to device using iTunes or iPhone Configuration Utility

I’d like to avoid using XCode when deploying the app to the device to better emulate what my QA team performs. They currently receive an internal app build file and then use iTunes to install the app to the device.

Are you using iTunes to deploy the app to a device? If so, do you know if there’s a way to automate that process, perhaps via AppleScript?

Thank you kindly,
Sargon