I\'ve Safari 8.0.6 with iOS 8.3 on my iPad, while debugging through Web Inspector on my Mac (10.10.3), the connection keeps on
Well, after so many trials and opening thousands of blog posts to figure out a solution, I managed to get it working without a single case of failure.
For me, this has been always a problem with my Ionic+Cordova application.
My subconscious mind started to think about this problem when I saw that this issue (of Safari getting disconnected) is not there when I run a plain simple Cordova or Ionic application. And then suddenly, I tried another thing and it worked.
Basically, the Safari web inspector disconnects when the size of any files are too large (not sure about the limit). Maybe, some image, some script, and CSS. In my case, it used to because of the JavaScript & their source map files.
So, when I started to run my iOS application without source maps, the problem is gone. For that, all I had to do is to pass --source-map=false
to my ionic cordova commands
like:
ionic cordova run ios --source-map=false
ionic cordova run ios -lc --source-map=false
I wrote a small article about this to elaborate this in detail https://medium.com/wizpanda/a-small-tip-to-speed-up-development-with-angular-or-ionic-d5764f639c0c
Most of the answers listed here worked for me for a while but after a few hours they also stopped working and my Safari web console again keeps disconnecting as it opens.
Other few options that worked for me:
Safari on MacOS -> Develop -> Empty Cache
On iOS Device -> Settings -> Developer -> Clear Trusted Computers
then reconnect the USB cable and then try to debug again
This solution is working for a long time now. Since this is an issue related to connection between iOS & Mac so I opened my Console app and just kept my iPhone selected. (This is somehow kept my iOS device connected to my Mac)
Then opening the Developer's console on Safari worked fine for me without disconnecting.
This is also a kind of workaround and a hack to see it functional. You can basically prepare your iOS app by ionic cordova prepare ios
and then run the app using Xcode and deploy it to your iPhone.
At least, I'm able to see the console logs and sometimes, it even works with Safari web inspector.
I think this is the most working solution. This option is suitable when your system is not running too many applications as firing a simulator suckup a good amount of system resources.
Basically, instead of running your app on a real device, run your app in an iPhone simulator via Xcode and debug it normally in your Safari web inspector and this problem will not occur.
This is probably because the files being transferred to Safari inspector is from the system itself.