ChatGPT解决这个技术问题 Extra ChatGPT

ios simulator: how to close an app

When you "run" the simulator from xCode, the app automatically launches, and then you can click the home button to suspend the app. What I want to do is close the app from within the simulator. So, how can this be done?

Please anyone share any automated process, some settings tweak which will kill the app in simulator when stop switch pressed for xcode 7.1 or later. I'm tierd of killing my app from double home tap & swipe up :(
@RatulSharker: Have you found the solution? I am on the same page, too tired to of trying the double home tap and swiping up. But all efforts in vain. Help!
@RatulSharker: Finally found one...!! After enormous amount of Brute Force..! Press: Shift+Command+Swipe up using the Touchpad.
:P i work on mac mini, no touchpad, i was intended to solution like change some preference in xcode or simulator :(
@RatulSharker as long as it is your own app, you can kill it from the IDE

J
James Webster

You can also do it with the keyboard shortcut shown under the simulator menu bar (Hardware-> Home).

The shortcut is ⌘+⇧+H, but you need to hit H twice in a row for it to simulate the double press that shows the apps.


By the way, trying this in iOS 7 presents screenshots of each running app; just swipe the screenshot upward to close it
@bababooey your comment should be one of the answers. I could not figure out how to do this and I looked for this everywhere! Btw, for anyone else that stumbles here, swipe up the screenshot not the icon.
The double-h tap is charmingly congruent.
Note to Future Self: That "up arrow" is Shift and not the keyboard "Up" arrow, kept wondering why it didn't work.
Perhaps worth adding: I sometimes have to do the double hit on ⌘+⇧+H, 3-4 times to finally simulate the showing of the currently running apps. Persistence pays off in this case.
C
Chicowitz

For iOS 7 & above:

shift+command+H twice to simulate the double tap of home button

swipe your app's screenshot upward to close it

You'll see screenshots representing the apps suspended on your device - those screenshots respond to touch events. Swiping is the gesture you'll make to "fling" the screenshot off of the screen. Note that on machines where your mouse is intended to represent your finger, you'll click and swipe as if it is your finger tapping and making the gesture.


Not a fare call bro, the Q was asked you and was responded by @lehn0058 on Aug 29 '13 correctly, now to get easy upvotes, you accepted your answer and modified by copying his. Not a fare call at all. Atleast mention the deserving persons name.
@Shyam It just needs to be quick. Quicker than on an actual iPhone. At least that is my experience with the new Xcode 11
R
Ray Hunter

On the new iPhone X, the simulator was having issues with the mouse/finger gesture.

You can do a long press with the mouse and a close icon will appear. You can use the swipe up gesture as well to close the app.

https://i.stack.imgur.com/F0UT3.png


you could also swipe up at this stage.
Go to app, hold mouse at bottom of screen (just below black line) and swipe up bringing the thumbnail to the centre of screen and release. Now long hold mouse over app and the close button will appear. Tap it to close the app completely.
Is there a keyboard shortcut for iphoneX only?, I was used to the (shift+cmd+H)+H to bring background apps but cant make it work for iphonex sim
FYI iOS12+ you need to swipe up this window to kill previously that sends it to background
A
Archit Kapoor

I had a difficult time in finding a way in XCode 7.2, but finally I had found one. First press Shift+Command+ H twice. This will open up all the apps that are currently open.

Swipe left/right to the app you actually want to close. Just Swipe Up using the Touchpad while Holding the App would close the app.


This is perfect. I am using XCode 10. Works there too. Thanks
m
matt

Window / Show Device Bezels

And now you can see the real device, so double tap on HOME button and kill you app


R
Rishabh Arya

You can use this command to quit an app in iOS Simulator

xcrun simctl terminate booted com.apple.mobilesafari

You will need to know the bundle id of the app you have installed in the simulator. You can refer to this link


T
Tulon

For closing (not quit) the running application in Simulator the keyboard shortcut is "shift+command+h".


K
Keshav Gera

Command + shift +h Press H 2 times

Note :- Press H 2 times


T
Tony

Double click on the home button and then click and hold the icon like a normal phone and then click close I believe.


This did close the app. I was hoping that I could select my app from the applist and then launch it again and continue debugging it from xCode; when I tried this, I got a SIGKILL exception.
@bababooey yes, a SIGKILL is the correct behaviour. There is no point re-opening it, because the program gets terminated when closed, so you are starting with a fresh new runtime when you re-open it.
That is common because at the time you close the app xcode is still attached i believe.... try hitting the stop button after you close then try opening again maybe. It is a little hard to know since I am not there haha
Ok, maybe I'll create a new question then; what I'm trying to do is to test launching my app from a URL; I wanted to launch it from a URL without having my app suspended in the background
Does this help? iosdevelopertips.com/cocoa/… is that what you are looking for?
J
Jerry Sam

Easy way, just click on "Device" menu then select "App Switcher".


Ö
Özgür Odabaşı

You can also kill the app by process id

ps -cx -o pid,command | awk '$2 == "YourAppNameCaseSensitive" { print $1 }' | xargs kill -9