title: Xcode Instruments throwing error "Could not start script, target application is not frontmost."
body: <p>I am currently adding UIAutomation acceptance tests for an existing iPad application.  I have a custom shell script that runs instruments from the command line and resets the simulator before running the tests.  When it tries to run the UIAutomation tests it fails with the error "Could not start script, target application is not frontmost."</p>
  
  <p>I tried troubleshooting this by attempting to reproduce it in the GUI version of instruments and was able to reproduce it.  It only happens the first time the app is launched after installation and it only happens in the iPad 6.0 Simulator.  When I run through the same scenario in the iPad 5.1 Simulator it works fine.  After launching in instruments on the 6.0 simulator, any UIAutomation script that I try to run on the app returns the "Could not start script, target application is not frontmost." error.</p>
  
  <p>The app itself is not doing anything special in the AppDelege.  It initializes the window.</p>
  
  <pre><code>self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
  </code></pre>
  
  <p>It creates a view controller and assigns it as the root view controller:</p>
  
  <pre><code>MyViewController *viewController = [[MyViewController alloc] initWithModel:self.myModel];
  [self.window setRootViewController:viewController];
  [self.window makeKeyAndVisible];
  </code></pre>
  
  <p>This is done in the didFinishLaunchingWithOptions method.</p>
  
  <p>I am doing something very similar in another app and do not experience this error.  I'm curious to see if anyone else has run into this problem and what they did to resolve it.</p>
  
  <p>I'm using Xcode 4.5.2</p>