An unknown error occurred when I was trying to use an iPad for development
This has happened to me a lot when I'm plugged in via the Apple USB keyboard (that has two USB ports underneath).
If you plug in more than one thing in that keyboard, like two iPhones, it won't be able to deliver enough power to both, and you start getting intermittent disconnections.
Solution: Plug in directly to the Mac.
One time this happened to me and it seemed my iCloud account on my device was not logged in. This was due to a password change I had done. Once I signed back in with the proper password the app seemed to build to the device just fine. :-)
Try disconnecting / reconnecting the iPad, quit and restart XCode, ... Sometimes it just won't work and restarting everything solves it !