Ionic "Invalid device state" Error with Xcode 7: Solved
Invalid Device StateOften when installing a node project using npm, our system may require use to use
sudoto 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
sudoto run the
ionic build iosand
ionic emulate ioscommands. So, when is it appropriate to use
sudowhen you are building an app with Ionic?
When to use sudoIf 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
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 FixHere are the steps you can use to correct this issue:
- Empty the 'platforms' folder in your Ionic project
ionic platform add ios,
ionic build ios, and
ionic emulate ioswithout
- 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