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?
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."
Then adjust the service receives section as follows
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.
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"
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"
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!
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.
Related
This is my first Swift app. Most of my coding experience is in C++ and C#, but I’m fairly new at programming.
I made a Terminal app, called PhotoSorter, using Swift. After building it, I pulled the executable out of the product folder in Xcode and ran it. It works great on my own laptop, but when I try to run the executable on another Mac, I get the following error:
“The alias ‘PhotoSorter’ can’t be opened because the original item can’t be found.”
Question: How are you supposed to create a Swift executable in Xcode that can be ran on any other Mac? Ideally, I want something that the end-user can just right-click/double-click to open.
Looking at your question again, I see you're using Xcode. In that case, the best way to distribute your program is to choose "Archive" from the "Product" menu, and when your app is done building, click the "Distribute App" button in the window that appears. Then you can choose your code signature and create a code-signed version of your app (or distribute via the App Store if you're into that sort of thing).
The immediate answer to your question, though, is that you're making an alias instead of copying the file. I assume you've used the mouse to drag and drop out of Xcode's "Products" pseudo-folder. The default action when you do that is to make an alias (which is like a shortcut on Windows). You can override that by holding down the Option key while you drag, but it's better to go the Archive route.
I'm building a Cocoa application with Xcode. I have to force-kill my app for unrelated reasons, and every time I do I get this popup:
The last time you opened MyApp, it unexpectedly quit while reopening windows. Do you want to try to reopen its windows again?
If you choose not to reopen windows, you may have to open and position the windows yourself.
[Don't Reopen] [Reopen]
What is this system called and how can I disable it for my application?
This is Cocoa's automatic state restoration in action. You can suppress it when your app is launched under Xcode by editing your active scheme, choosing the Run action, and checking "Launch application without state restoration".
Note: Disabling this will also disable automatically-reopening documents that were opened previously, which can be a pain for testing a document-based application, since you'll have to re-open the doc manually each time you run it. This also only disables state restoration while being run under Xcode under that particular scheme.
I sometimes get a dialog in Xcode which states "Simulator in use." Restarting Xcode didn't help.
I have no Simulator Icon in the Taskbar to quit it and I have no running Simulator.
Is there any solution without rebooting?
I know some of these points to not adress your specific issue since you wrote restarting Xcode would not help you but I'll try to provide a full list of possible fixes for people who might stumble upon this one day.
Is the "Stop" Button in the left corner of Xcode still clickable ? ==> Click It
Try to reset contents & settings of iOS Simulator
Clean Build & Clean Project
Quit iOS Simulator (look at the Activity Monitor if there is still something running)
Restart Xcode
Restart Mac
This is all I can think of. For me most of the times I can resolve it by just restarting Xcode. As you wrote this does not work for you so maybe some of the other points of my list will help you.
Normally this happens when you terminate the iOS Simulator but not the debug session itself, which is why most of the times the "Stop" button in the left corner is clickable most of the times...
This dialog (and the state that triggers it) comes entirely from Xcode and not the simulator itself. This dialog will present itself if Xcode is already using the simulator from another workspace. For example, if you have three projects open at the same time and you do a Build&Run (eg: click "play") in one of them, you will get this dialog if you do a Build&Run in one of the other projects.
When I run my ios8 action extension on the iPhone simulator it gives me a list of apps to act as host, but it only offers 'today' and my own app even though I have specified the following in NSExtensionActivationRule in the plist:
NSExtensionActivationSupportsImageWithMaxCount:1
NSExtensionActivationSupportsWebURLWithMaxCount:1
so I would have expected safari, photos etc.
You may want to forego launching the extension directly from the simulator.
I've been debugging extensions all week and what I'd suggest is this (not too long) process:
Launch the app so that your latest version of the extension is
loaded onto the simulator.
Then stop the app so the simulator is not in use.
Attach to the extension via this Xcode menu Item: Debug->Attach to Process->By Process Identifier (PID) or Name
Xcode will now say "Waiting for 'EXTENSION NAME HERE' to start" and may prompt you to "take the appropriate action"
(On the simulator) Launch Safari (or the appropriate app) and interact like you would if Xcode had launched it on your device.
Once your extension is run, Xcode will attach and you can debug
I would recommend binding that menu item to a keyboard shortcut (I used Opt-Shift-Cmd-A because I hate my carpal tunnel) because it's two items down and the stupid attach menu loads all the active process AFTER it opens so the item you want jumps to the top of the screen.
Once you load the extension you can keep re-attaching to it if it crashes without having to relaunch the containing app.
This has sped up my debugging process quite a bit.
Create action extension involves the following three steps
1) Create a Target with "Action extension" template
2) Goto iPhone "Photos" app and choose a photo and click Share icon. It will show "Share" activities(FB, Twitter, etc) and "Action" activities(Copy, Slideshow, etc). Goto end of "Action" activities and click "More" button
3) In the "Activities" page, you have to enable your "Action" extension
I have run into a rather annoying bug in Xcode 4.3.2.
If you run a process from within Xcode, then stop the simulator directly (outside of Xcode), Xcode still shows the process as running and effectively disables any further interaction with the simulator.
I can't stop the process from within Xcode (no response), and I can't start a new process either as Xcode sees the simulator as being in use. Shutting down the simulator does not notify Xcode either, so I have no option but to shut down Xcode and open it up again But even that does't work as Xcode hangs whilst trying to shut down the process too! So I have to force quit Xcode!
Has anyone found a way round this? I realise I should now only operate the simulator from within Xcode, but I am used to being able to operate the simulator independently.
thanks
I was having similar issues with Xcode 4.3.2. I fixed them by doing the following:
Launch Xcode.
Close any open projects.
Open Organizer.
Delete project form left panel using the gear icon on the bottom left. Select "Remove from Organizer...". This clears all the data about your project that Xcode has cached (indexes, DerivedData, Snapshots, etc.).
5). Re-open project.
Since doing this, my Xcode hanging issues have disappeared.
Here are the steps I follow when this happens:
Start the simulator if it isn’t already running
Choose the option “Reset Content and Settings…” from the iOS Simulator menu
Clean and rebuild the project