Multiple projects using the simulator
Asked Answered
A

2

1

I am comparing the run of multiple projects using the Xcode simulator. Each time I go to build in one project after having run one of the other projects Xcode tells me that it cannot perform the build and run because the simulator is in use. I then have to find the other project window, stop the run in the simulator (Cmd-.) and then switch back to the previous window and rebuild. Can I make a single keyboard shortcut to stop the current run in the simulator, build and run the current project in the simulator?

Addams answered 4/3, 2012 at 3:11 Comment(0)
H
5

There is a little bit of doing involved in making this happen but overall it's pretty easy.

The first thing you'll want to do is open Automator. Incase you've never used it before, it is included on your mac so just search it. When Automator launches, you will be prompted to create a new project, select "Service." enter image description here

Then adjust the service receives section as follows enter image description here

On the left side of Automator, you'll see a search pane, search for "Run Applescript" and then drag the instance of "Run Applescript" under your service receives section. enter image description here Now you're going to want to change the applescript to suite your needs. In this case you'll replace "(* Your script goes here *)" with "tell application "iPhone Simulator" to quit"

enter image description here Once you're done altering the Applescript, save the automation as whatever you'd like, it will show up in Services under this name.

Now you're going to head over to "System Preferences" and search "services" enter image description here As you can see, I named my Service "Quit Simulator" select yours and define whatever shortcut you want for it. (Try not to conflict with existing shortcuts!)

And now if you encounter the "Simulator in use" error you can quit the simulator, ending any current process with a simple keystroke.

Hope this helps!

Holden answered 4/3, 2012 at 7:0 Comment(1)
Taking this one step further, would it be possible to execute this script automatically every time you successfully build (using the xcode preferences on build options). Also, it'd be ideal if this script only ran when the simulator was currently running an app. Perhaps instead of a quit command we could script it so that it just navigated to the home screen of the simulator?Pizza
O
2

Each run is dependent to their project window (as far as I know). So you'll have to go to the project window and stop the build, or simply quit the Simulator (cmd+q) and build again in your new project.

Oceangoing answered 4/3, 2012 at 3:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.