iOS Simulator: Invalid device state - ios

I just downloaded Xcode 6.4 from App Store and started to create a hello world app to learn swift but I get the error saying "Invalid Device State".
I googled a lot and tried the below things:
Restarted Mac and entered xcode and started project (as mentioned in a stack overflow thread)
I created a new iOS app with another layout but showed the same error again if I ran that project.
I deleted all projects and re-installed Xcode again. Started a new project and ran it but still getting the same error.
I am running Yosemite 10.10.1 and the Xcode version is 6.4.
Can anyone help me ?

Devices can get stuck in the creating state if errors occur in older versions of Xcode. This was fixed at some point in Xcode 7, but I'm not sure if the fix made it back into an Xcode 6.x release.
From Terminal.app, please run 'xcrun simctl list'. Locate the UDID of the device that you are attempting to boot. If it is stuck in the 'Creating' state, you can try recreating it by running 'xcrun simctl erase '.
If it is stuck in a different state, please update your question appropriately to indicate which state the device is stuck in.
On a side note, I suggest you update your OS. There have been a lot of quality fixes since 10.10.1. 10.10.5 just came out.

Try to switch from your original simulator to new one (for example from iphone 6 to 6plus) and then switch back to original one (iphone 6) and it should be ok

Related

Xcode 8 | iOS 10 simulator "Error returned in reply: Connection invalid"

While I am try to run an app in the iOS 10 simulator using xcode8 I get these alerts frequently. They randomly appear two at a time and it is not apparent what is triggering them.
Below is Image for Error I got.
I tried Following things.
Clean & Rebuild an app
Restart xcode & Simulator
Clear Derived Data & Rebuild application.
Even I was getting the same error. Issue in my case was I was working on xcode 7.3 and its simulator was open, later on I closed xcode 7 and opened xcode 8 and tried running app and got the above error.
I guess its happening because of both the simulator were open, it got solved when I closed my older simulator. Seem to be some problem while xcode 8 was trying to establish connection with simulator.
You just follow these steps to remove this error it's working fine in my side and i hope these steps work to you also just try it.
i)Remove multiple xcode versions.
ii)Quit all Xcode and simulators.
iii)Only one version you opened.
iv)Go to Xcode -> Preferences
v)Go to Location
vi) Set proper version for command line tools (your Xcode version)
vii)click on Derived Data
viii)Then go to Derived data and delete that folder. see below image
ix) Click on Simulator reset content settings and just quit xcode and simulator and open clear and build the xcode and run it.
Without deleting "Derived data" folder
The same rules as in the past apply to switching between Xcode 8 and
Xcode 9:
Quit Xcode, Instruments, Simulator.app, and Console
xcode-select the version you want to work with
Start the version of Xcode you want to use
If these steps don't resolve the problem for you, you can repeat the steps above > but after #2 add "sudo killall -9 com.apple.CoreSimulator.CoreSimulatorService".
from this https://forums.developer.apple.com/thread/79301
The Same issue I have faced when I have two Xcode version, but the issue was when we are opening the two instances of simulator we will get the same error, the best way to solve this issue is run command
rm -rf ~/Library/Developer/Xcode/DerivedData
to remove the derived data.
None of the above worked for me.
Instead of choosing the simulator and hitting "run" i solved it by opening the simulator form "Open Developer Tool" menu first. After that all worked fine.
I had a similar issue, despite not launching a second instance of the simulator, due to using SimPholders and having the XCode Command Line Tools set to a different version of XCode. To resolve this, open up XCode preferences, and under the Locations tab ensure that the Command Line Tools version matches what version of XCode you're currently working in.
I had the similar issue shown in below screenshot.
Got it solved by closing Xcode 7 and its simulator.
It seems that when you are working on Xcode 8 and its simulator then Xcode 7 simulator should not remain open.
Below is screenshot of simulator state for Xcode 7 when you're working on Xcode 8.
In my case,
I was open a project a Xcode 8, and the emulator for this version, then open this project on Xcode 7.3.1, when I create an emulator it shows the alert.
My Solution: Close all version of Xcode => Clear Derived Data => Quit Xcode => Open Xcode => Choose File => Open Recent.
Force Quit.. Xcode and simulator. This kind of issue happned because maybe you are try to run more than one different version Xcode at same time.
I just had this issue when attempting to debug an iOS application from Xamarin, which uses Xcode to run apps in the simulator. I was initially targeting a 9.7" iPad Pro, attempted to change the simulated device to an iPad Air 2 (still on iOS 10), but the simulator didn't respond. After quitting and relaunching the simulator it appeared to load okay, so I changed back to the previous device - not sure whether changing devices actually did anything but I haven't seen the error message in the few times I've run my app since.
Solved it by closing all xcode and simulator. Don't ask me why. It was happening on the beta version for me
I had similar issue, what I did is I closed the simulator and all the Xcode and I went to the terminal and typed to see any Xcode application running then I killed it. I had one Xcode running in the background.
Command to see if Xcode is running,
ps -e | grep -i xcode
Use kill comment to kill any runing Xcode app, I used
kill -9 <pid>
The Same issue I have faced
in my case i stopped all applications and restarted my mac
and every thing is OK
Simple And fast Remedies..
1.Quit all xCode and reopen the xCode which you need to work...
I had this problem too, but I did below process it's working fine.
You have both Xcode 8.x.x and 9 running on your Mac, which causes the problem. Only run one Xcode at a time (Quit another Xcode, don't let another Xcode runing in background!).
This can occur when you have more than one version of Xcode installed on your computer. Make sure you QUIT (not just close) all versions of Xcode first.
Changing the device seems to have worked for me after doing the other stuff. Didn't have to restart my computer.

How to fix Xcode "DTAssetProviderService could not start.." error?

I have upgraded macOS Sierra Developer Preview, but my Xcode 7.3.1 gives below error while try to run my project on simulator. In addition Generic to archieve gives another error like:
In addition for archive: a cryptographic verification failure has occured.
How can I fix this?
I have tried before Xcode 8.0 Beta, uninstall it deleting derivedData and reset content simulator but still occurs this error.
Update:
I want to share an information who want to use Sierra now. If you decide to do below changes you need to know "Uploading App Store with beta software" not allowed by Apple. Continue with El Capitan and Xcode 7.3.1 for production.
If you want the slow solution, you can reinstall Xcode 7.3.1 by downloading it from https://developer.apple.com/download/more/.
It worked for me and now my Simulator is able to start again without getting the error.
The issue is discussed in depth here:
How to fix Xcode "DTAssetProviderService could not start.." error?
This seems to be a major bug. Until Apple fixes it, you can work around it:
Build app
The app will still install on the simulator, even with the error
Launch the app manually on the simulator
Go to Xcode
Click Debug > Attach to Process > Your App Name
That will enable Xcode debugging features and allow your app to run in simulator. Definitely not ideal, but hopefully you can use this until a real solution comes out.
This is a regression in macOS Sierra that multiple developers have reported in the forums and in the lab sessions at WWDC. Xcode 7.3 is not supported on Sierra. If you want to use macOS Sierra, please use Xcode 8.0 beta or later.
If you must use Xcode 7.3 on Sierra, you can partially workaround this bug by using Xcode.app to install the app through Build & Run, launch the app suspended from the command line (xcrun simctl launch -w booted <app identifier>) and then attach with the debugger and resume the suspended process.
Note that this issue only impact Xcode 7.3.1 downloaded from the Mac App Store. You will not hit this issue if you use Xcode downloaded from http://developer.apple.com (ie, the "drag & drop installer"). Note that you might hit another issue with the same symptoms when using the drag & drop installer. That is discussed in DTAssetProviderService could not start DTXConnection with Simulator
You can still run the debugger, but you have to attach it manually.
You can run your app tapping the icon in the simulator, than switch back to Xcode and select Debug, Attach to Process and pick your app process.
The following steps fixed the issue for me:
Remove both Xcode 7.3.1 and 8 Beta
Remove /Library/Developer and ~/Library/Developer (before removing check the contents and back up whatever you need)
Download the Xcode 7.3.1 DMG file and the Xcode 8 Beta xip file (unless you already have them)
Install 7.3.1 and test the Simulator (should work fine now)
Install 8 Beta and test the Simulator in 7.3.1 again (should work as before)
Restore what you backed up on step 2

xcode 7.3.1 Invalid Device State

I upgraded to OS X 10.11.5 and Xcode 7.3.1 a few days ago and all seemed well. Then today after adding my new iPhone 6s Plus to the device IDs in my developer account and having Xcode do an automatic 'fix issue' to update the provisioning profile when trying to run my apps on my new device, I am now getting Invalid Device State errors on all my simulators in all my apps. Running the apps on my new device works fine, but all the simulators give me the error. I tried the solutions found here iOS Simulator: Invalid device state and here Invalid Device State - Xcode/iOS Simulator error but neither have resolved my issue. When I run xcrun simctl list all the devices show a status of Shutdown, which I assume is what the status should be. I then run xcrun simctl erase all and I get no errors. I then did a clean build and a clean build folder, and restarted my Mac, and still the error occurs after doing all these steps. This is really frustrating, and I hope someone can point me in the right direction. I always get nervous when it comes to upgrading OS X and/or Xcode because more often than not something breaks in my apps, or something like this occurs.
I tried everything possible to get this to work for two days. Finally I re-installed Xcode and that did it. In case someone runs into this issue and the regular solutions do not work, don't waste your time trying to figure it out, just re-install Xcode and save yourself some time.
just quit xcode and simulator. it will resolve the problem.

Xcode cannot run using the selected device error in iOS 8

I tried to run my iOS app on iPhone 5 using Xcode, but when I connected it, the iPhone didn't show up in the top-left selection pane. And also when I ran the app from within Xcode, the error: Xcode cannot run using the selected device error occurred.
After that, I found that my iPhone was not even found in the organizer; it was there previously. However, after upgrading my OS X to Yosemite beta and iPhone to iOS8 (officially released version of iOS 8), everything doesn't work any more...
The last time I was able to run my apps on iPhone is 5 months ago, so I'm not sure when there's something wrong occurred during the period...
I cleaned and rebuilt the app, and restarted Xcode, but nothing worked.
I also confirmed that I use Default compiler in Build Options's compiler settings.
So what am I missing?
I had same problem. Problem is that your xcode is running on v.5 and there is no option to choose iOS 8 as device system. Try to update your xcode over appstore to v.6

An Unknown Error occurred in Xcode

I'm trying to test out my app on my ipad and when I decide to run it on my ipad, Xcode says that it's successfully built. On the top, it says that it's runnning the app, but nothing happens for 2-3 minutes. Finally, I get two screens popping up saying "An unknown error occurred." I have tried running other apps through Xcode on my ipad and they work fine. I also decided to exit Xcode and restart everything, but the problem still exists. Does anyone know what the problem is?
Not sure if this will be useful but
Xcode Version: 5.1.1
Ipad Version: 7.0.4
Mac OS X 10.9
I found one approach:
Before this approach make sure that you have all certificates and other documentation updated.
I have faced same issue, now I have a way to fix this. I am using iPhone 5 with OS version 9.1
First, delete the app from your device and then restart the xcode by force quit and then again open it. Now clean your project and run the project in your device. Now it will be run without any issue.
Close your simulator or unplug and plug back in your device, and re-select the device target.
In my case . I cleaned the product and rebuild it and it worked.
Sometime is you forget to unlock your device.

Resources