Best Way to Reset iOS Simulator - ios

xCode 4.5 will occasionally hang when building and running when the app under development is running in the simulator. The anticipated response is the app running in the simulator will stop and the new build will be started in the simulator. This state will not allow xCode to stop tasks or close/quit. xCode responds that there are tasks in process and will not stop these tasks. Is there a preferable solution other than force quitting xCode?

Actually quitting the simulator 99% of the time solves the issue.
Right click on simulator icon --> Quit
And Xcode will build the new version and launch it in the simulator

In some cases quitting the simulator does not help, then you should do iOS Simulator->Reset Content and Settings... this will kill all applications on your simulator, but sometimes it is very useful though.

xCode will not allow a quit action because tasks are running and will not stop or build in current state.
Ignore xCode state
Change simulator type in xCode's device scheme
Build/run app in the new simulator, this may cause the developer's app to crash in the simulator.
Change device scheme back to original selection.
Build/run app

Related

Xcode 12 Apple Watch Debug Cycle

I just got back into iOS / WatchKit development after a ~8 year break. I'm having a really hard time making an app for the watch, because
Simulator is not helping because random things seem unsupported (most recent example being WCSession.transferFile, which apparently is a bug)
On device is not helping because the loop to get it to run on device is completely out of hand, and I was not able to get either logging or debugging to work when running on device. (My main problem is that if I do CMD R in Xcode with my Watch selected as target, it builds, and says running, but never launches the app. If I launch the app manually I find it's not the most recent version. I have to go and remove it from the watch, and re-add it, which then causes Xcode to not be able to run it anymore, which means I have to restart Xcode. What.)
So my question to more experienced devs is: what's your debug cycle when writing Apple Watch apps?
I'm running Xcode 12, watchOS 7.1, on Mac OS 10.15.7 (not Big Sur which may be some cause of issues)
Some steps that help for on device debugging:
To re-install the watch app, select the iPhone app in Xcode and build and run that. This will also re-build and re-install the watch app as needed.
Open the app manually on the watch
I still haven't figured out how to get a debugger or console, but for now my hack is to have a label on the watch that I use as my on device console.
This is almost certainly an Xcode 12 issue. At least since Xcode 12.5 my app has not worked with watch simulator (it can't connect to the phone simulator) and I get no debugger with a real device.
Using Xcode 12.3 seems to work.

Xcode doesn't launch the watchOS Simulator

Problem
Xcode (9.4.1) doesn't launch the Simulator app at all when I try to run a watchOS app.
Steps to reproduce
Select the scheme
Hit run
Build succeeds, waiting to attach.
And here is where it gets stuck. Nothing happens from here. The Simulator app never gets launched.
Simulator Launch Workaround
The Simulator can be opened manually. Then, Xcode installs the watchOS app on the watchOS Simulator and the iOS app on the iOS Simulator.
But here is the next problem: Once it has installed the apps it doesn't launch the watchOS app, even though i've set the launch to Automatically in the Scheme Editor.
watchOS App Launch Workaround
Go to the watchOS home screen and tap the app icon to open it.
I know that all the workarounds should not be necessary. And it all worked before.
Other information:
I had installed the Xcode 10 beta 3 recently but I removed it already
I removed the derived data
I had to virtually connect the watch and phone via simulator to get it running. Like you would on iPhone to get it connected.
I found it odd but after that I had no issues. Go to the watch app via the iPhone simulator and pair the virtual watch then Presto!

Invalid Device State - Xcode/iOS Simulator error

Problem: I cannot simulate an Apple watch interface. Whenever I try and test my Apple watch app on the iPhone 6 simulator, Xcode successfully finishes and builds the app, attempts at opening simulator and fails with an error message which reads 'Invalid Device State'.
I believe simulator has a watch simulator that opens along with the compatible iPhone simulator models that can communicate with Apple watch (example: iPhone 6) Although I have yet to see it work. I have built a universal interface for iPad and iPhone and another for the watch, so it's not a matter of the app being for the wrong device. Whenever I test on my actual iPhone I can test the universal interface successfully.
I'm using Xcode 6.2 on iMac OS X 10.10.3
I have tried restarting Xcode/Computer. I can't seem to find any other mention of 'Invalid Device State' anywhere, hopefully due to it being an obvious thing to avoid/fix that I've overlooked. Any help would be appreciated.
Force Quit xCode and restart will resolve problem.
I had come across this issue after updating Xcode 6.4 to 7.1.
Below are fixes for this :
Clean project (cmd+shift+k) as well as clean build folder
(cmd+shift+k+option)
Quit simulator and run again
Quit Xcode and Simulator and run again
Restart your Mac.
Solution 3 worked for me!
I had the same issue. Generally it is because you just update Xcode or change its name in the Applications folder.
If you just restart your computer it will work correctly.
Hope it helps !
I observed this happening when more than one Xcode app installed.
To fix this,
Launch Xcode and click preference..,
Go to "Location" Tab, Select correct options from "Command Line Tools" dropdown
Quit Xcode and relaunch it.
Run your app.
First of all, just clean the project.
Quit your project.
Quit your Xcode.
Restart Xcode.
This happens to me when I have two different Xcode versions running at the same time. Hopefully this helps you.
No need to quit, restart or even re-install. Switch to another iOS Simulator device (6s if you were using 6s plus) and voila!
Nothing worked for me on XCode 7.3.1.
Had to reinstall it to make the simulator work.
Go to applications folder. Drag drop XCode to Dustbin.
Empty dustbin contents.
Go to App Store and install XCode.
Run XCode. The simulator should work now.
I have Xcode 7.3 and Xcode 8.0 Installed.
If a am working with Xcode7.3 and opens Xcode8.0 to get some code from Xcode8.0 project.
When i run my application on Xcode7.3 So it will give me same error.
Solution is simple ForceQuit or Quit all Xcode's and open the required one.
In my case, the simulator would show an indefinite black screen whether attempting to run a project, or running the simulator directly (which should bring you to the simulated home screen). This would happen even on a newly created simulated device.
After the existing suggestions failed, the following worked for me:
Delete the Simulator
Delete XCode
Delete the Developer folder
Reinstall XCode from the app store. This requires attempting to run XCode again so that Mac OS will realize it's no longer installed.
Jus clean the project and restart Xcode. This happens to me when I have two diffent xcode versions running at the same time.
Robust fix is Just Quit your xcode and run again, hope so it will help you. This heck work for me.
On M1 Mac I've found more than 3 open simulators can cause this error. Quit the simulator app to fix this error.
I am pretty sure that in my case the simulator was corrupt after a failed language change.
Following this answer to reset the simulator worked.

How to build application in Xcode without launching iOS simulator?

I recently purchased an Apple developer's license so I can make apps using Swift
However, whenever I build my app, it takes about five minutes to load, and opens up the iOS simulator which is extremely slow.
How can I build just the app itself?
Thanks.
I had the same problem, and the solution is quite simple.
Don't close the iOS simulator, leave it open.
Just stop the app from running, and it will close the app within the simulator itself.
CommandR to run the app, Command. to close.
You did a "Build & Run" with an iOS Simulator device selected as a run destination.
Select a real iOS device in the run destinations list and B&R to it instead (or just Build rather than B&R).
Just press cmd+B to build without running simula.

Can I run an iPhone app from Xcode without debugging it?

Is it possible to have Xcode automatically launch an app on my iOS device from Xcode 4.6 without attaching its debugger to the app? I'm working on an automated build system, so manually launching the app is not an option.
I've found Run Without Building under the Product -> Perform Action menu, but that still attaches the debugger. I can edit the scheme to make Xcode wait until the app is launched manually before attaching the debugger, but that's basically the opposite of what I want.
If you want to launch an app from Xcode without launching the debugger, I would uncheck the “Debug executable” option in the Xcode scheme:
If you want to launch an app manually, you can:
Select your device in the "scheme" dropdown;
Build the app (don't run);
Open the organizer and go to the "devices" tab;
Drag your app from the "Products" folder in the main Xcode project navigator to the device in the organizer window and it will be installed; and
You can then run the app manually from the device at that point.
This process can be useful when diagnosing startup performance and you want to run the app on the device completely separate from Xcode (and the debugger, if you have a debug build).
xcode 6.3.1
unselect the debug execute, then you could run without debugging.
Just Build and run and once it launches press stop and open the app manually. It will then be the app you built but not connected.

Resources