Multiple projects using the simulator

2019-06-03 05:21发布

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?

2条回答
劫难
2楼-- · 2019-06-03 06:10

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.

查看更多
Deceive 欺骗
3楼-- · 2019-06-03 06:12

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!

查看更多
登录 后发表回答