Ionic “Invalid device state” Error with Xcode 7: Solved
I’ve been working on an Ionic Framework project for a while now. Just recently after I upgraded to Xcode 7, however, I couldn’t get a project to install on the iOS simulator. Every time I would build an emulate the project, the process would fail with an “Invalid device state” error. I tried a number of things: rebooting my machine, reinstalling Xcode, etc. What I discovered, however, was the root of this problem had nothing to do with Xcode 7, but instead with file permissions.
Invalid Device State
Often when installing a node project using npm, our system may require use to use sudo to execute the command without error. At some point, however, we may  choose to use sudo when it isn’t necessary. In the case of the “invalid  device state” error, that’s likely what’s happened, especially if you  are using sudo to run the ionic build ios and ionic emulate ios commands. So, when is it appropriate to use sudo when you are building an app with Ionic?  
When to use sudo
If you look closely at the error produced when a build fails, you also see an error like this:
  no such file or directory, stat '/Users/username/Library/Logs/CoreSimulator/D2FFF2E1-C3D2-4D1A-ABE2-242D3EAEDFC7/system.log'
  This was a little odd to me. Even though it told me it didn’t exist, I  felt like the system really just couldn’t see that system.log file.  This is when I suspected a permissions problem.
  When you use the Ionic Framework Getting Started Guide, you’ll notice that node of the ionic commands use sudo. It is perfectly fine (and sometimes necessary) to use sudo with the npm commands, but don’t use sudo on the ionic commands.  
How to Fix
Here are the steps you can use to correct this issue:
- Empty the ‘platforms’ folder in your Ionic project
 - Re-run 
ionic platform add ios,ionic build ios, andionic emulate ioswithoutsudo - If you are on a Mac and are still getting a permissions error, make  sure all the files in your user’s home folder actually belong to that  user by running 
sudo chown -R username /Users/username 
That’s it!
You should now be able to build, emulate, and launch your Ionic app without hitting that pesky “Invalid device state” error.