Cordova - Safari iPhone remote inspection disconnects - ios

I'm using the Safari Web Inspector to remote debug a Cordova app I'm building. Previously this has worked like a charm, but now I've run into an issue. After launching the inspector, after a couple of seconds it seems like the web inspector disconnects from the device. The inspector is still open, but the inspector wont update, and elements on the device wont be highlighted anymore when hovered in the inspector (this works for the first couple of seconds). I'm able to get it running for a couple of seconds again by closing the inspector and launching it again.
I've tried debugging using Chrome and ios_webkit_debug_proxy instead, which doesn't disconnect. However, this has other issues which makes it a none viable solution.
I've tried using Safari Technology Preview (11.0 R35) as well as the current stable version of Safari (10.1.2), but the issue occurs in both of them. I've also tried switching the lightning cable and USB-port on my computer, which doesn't make any difference.
I found that the following error is logged (using the Console app) when the inspector seems to disconnect:
RWIServiceLockdownConnection: Disconnecting because we failed to read a message from webinspectord. This could mean almost anything.
This does seem to have something to do with Cordova, since the error doesn't occur when I inspect a regular page Mobile Safari page.
What could cause this, and how do I resolve it?

Try setting a global hotkey:
Go to System Preferences -> Keyboard -> Shortcuts -> App Shortcuts.
Add a hotkey, whatever keys you want (e.g. Cmd + Alt + I) and match that hotkey to your cordova’s main html file (e.g. index.html).
Launch Cordova App.
Open Safari WI & close it.
Re-launch Safari WI with quick hotkey shortcut set above.
Close & re-open cordova app, Safari WI should keep debugging.
Also, as stated in comments, try keeping Xcode open.

Related

Universal links (Deep linking) not working on iPhone but works on iPad

I am trying to build deep linking feature into my app. I did all the necessary set up for deep linking to work like, enabling associated domains in my app, adding apple-app-site-association to the root directory of my server, and I am serving a valid apple-app-site-association over https, I also validated my apple-app-site-association using this tool Validate your apple-app-site-association.
After doing everything right, I tested the deep linking feature on my iPad and it worked as expected. But when I tried to do the same on my iPhone it doesn't work, it always took me to safari. I tried it on 6s device, I reinstalled the app, I cleared Safari website data & cleared the history. Also updated the iPhone & iPad to iOS 9.3.5. The updating the OS didn't change a thing.
iPad still continue to work with deeplink URLs just like it did while it was on 9.3.4. iPhone still opened the link in safari.
Please give me some pointers on how to workaround this issue, I think this might be an apple bug but again I don't understand how it can work on iPad which is running same software as iPhone. Any help or guidelines is much appreciated.
Thanks.
I was able to fix this issue and this is one of the annoying issue that I have come across, because it doesn't say what is going wrong.
Fix: Whenever the iOS opens your link in safari, you need to pull down the webpage in safari and there you'll see a banner saying that, open it in the app. Once you click on that banner your future links will start opening the app instead of opening it in the safari browser.
There was no error whatsoever and there was no indication why the link was getting opened I am pretty sure that, iOS didn't download the apple-app-site-association whenever I installed the app.
Also note that the banner in the webpage will not be visible whenever your link opens up in safari, you need to pull down the webpage and then the banner will become visible and if you click on open in app banner, it will start opening the links in app.
If in future if you select to view the link in safari by clicking on context menu which appears on right hand side of the status bar, which will be saying "Open in [your app name]" in safari, the links in future will open in safari instead of app, and again if the banner open in app isn't visible, you have to pull down the webpage to see that banner.
HTH.
In iOS 13, similar problem of direct links not opening the app instead it open the safari website directly.
Fixed by updated the below safari setting...
Settings > Safari > Request Desktop Website > All websites > Switch Off
I was facing the same issue in iOS 12, on one device the link redirected to my app and on another device it was always redirecting to Safari and pressing the link on the Notes app was only allowing me to open it on Safari.
What I believe happened was that I pasted the URL in the browser and clicked Go, as I thought it would redirect to my app. No matter what I did ( reinstalling the app, restarting the device, ... ) the results were always the same, redirecting to Safari.
What helped me was deleting the cached data for my domain ( Settings -> Safari -> Advanced -> Website Data -> Swipe and delete the data for your domain ).
After that, everything started working.
I believe this is a bug with iOS Simulator,
In my case it was occurred when I entered an invalid address (with multiple spaces) for example:
Valid One: myApp://order/10003101
Invalid One: myApp://order/1003131
It stopped working even with Valid One and the solution was to clear Safari Website Data:
Go to Settings/Safari -> Clear History and Webstie Data
Device: iPhone 12 Pro Max
iOS: 14.5
Xcode: 12.5

Remote debugging iOS webapp - stop OSX Safari web inspector panel closing

I am debugging an iOS webapp (saved to desktop) with Safari 7.0.3 and an iOS 7.1.1 iPad attached via USB.
This is working ok, but to see changes after editing the code I need to close the app and re-open, which causes the Safari web inspector to disappear - every time I need to go to the menu and click Develop > iPad > myApp, which gets exhausting after the 100th time.
Is there a way to test a webapp without the web inspector panel closing?
How about if you just send it Javascript in the debugger console to make it reload:
window.location.reload()
?

Why is Web Inspector showing me "no inspectable applications"?

Background
My company recently made a shift to app development. While developing and Q/Aing on Android was relatively painless, iOS, on the other hand is proving to be a pain.
The task involves looking at the page source of our app (which has a custom browser). I heard that Web Inspector is a great tool, so I went with it.
Problem
First of all, Web Inspector has been able to detect the custom browser before.
But quite frequently, Web Inspector's menu gives the "No Inspectable Applications" prompt.
This happens with the exact same version of the app that worked earlier.
There seems to be no trigger whatsoever; yesterday Web Inspector was working with the custom browser, and then after a few hours (during which I may have disconnected and reconnected the iPhone) it stopped working.
I have not been able to figure out why despite breaking my head for a week.
Observations
I have an iPhone 4S running iOS 7.0.4. My Mac Mini has Safari 7.0.
In the phone options
Web Inspector is turned on in the iPhone menu
All privacy modes are set to off - Do Not Track, Block Cookies, etc. (this question)
Javascript is turned on in the phone.
In Safari on my Mac Mini
- Develop menu is enabled (obviously)
More observations
iOS Safari is detected by Web Inspector.
So, how do I go about debugging this? What could be a possible cause and what could be the solution?
I was having the same problem, it was cause I was running iOS 8,fixed by updating Safari to 7.1 .
An update for iOS 9 (using OSX El Capitan):
On your mobile device under Settings -> Safari -> Fraudulent Website Warning = OFF [default = ON]
For me to make it work I needed to go into iPhone's Settings -> Safari > Advanced and enable Web Inspector option. (iOS 9.1)
I was having exactly same trouble. I managed to correct the situation by clearing the cookies and history from the mobile Safari menu. After this, it showed up in the Mac Develop menu.
Hopefully this will correct your situation as well.
this is probably an oversight where someone forgot to include the ios 8 version of Mobile Safari as an inspectable application. Get with it guys. I was able to connect my iPad to a MacMini we have with Yosemite Beta.
So I have also discovered that the web inspector in Yosemite Beta doesn't inspect well. I am able to Breakpoint in Javascript, but items are not inspectable in the inspection pane. The console does report correct information. Don't be fooled as I was! To inspect the value of something in this web inspector you must access the values via the console, type in the variable and it will return the result it has correctly.
As it happens, the solution that worked for me (reliably) was:
Build the app from source locally (in Xcode)
Deploy it to the iPhone, connected through USB
For some reason, Web Inspector works reliably when the app is started this way. I am unable to figure out why, but it works. Comments welcome.
Here's a possibility, mostly because I just ran into this myself...
Is your browser set for private browsing?
If it is, turn that off! You can't use the inspector while it's on.

iOS6 - How to Clear Cache of Homescreen/Standalone Web App?

It would appear that Apple have changed the way homescreen/standalone web apps work in iOS 6. According to various blog posts (example) these apps now get their own dedicated space for storing their cached files, sqllite dbs, local storage etc, rather than sharing with the Safari browser like before.
Before iOS 6 when developing I used to go through the following procedure religiously to clear the cache...
Remove app from homescreen.
Close all pages/tabs in Safari.
Finally "Clear Cookies & Data" or "Clear Data" in "Settings" > "Safari".
Unfortunately now that Apple have moved the goal posts this same procedure doesn't seem to work. After clearing, even though my changes are picked up in Safari, when I add to the homescreen and launch the app the old HTML,JS etc is still picked up.
Does anyone know how to reliably fully clear the cache in iOS 6?
I can't verify the cache being cleared properly but this worked for me :
In order to do this, you need to allow Web Inspector on your iOS device.
Go to Settings > Safari > Advanced > Web Inspector (it has to be active)
And you have to activate the developer menu on your computer's Safari.
Go to Preferences > Advanced > Activate Developer menu
Connect your device to your computer with the USB cable
Go to safari > Developpement > Your Device name > Inspect an App (The app has to be running)
This will open The inspector on your computer for the web app
While the inspector is open Clear the cache (command + alt + E)
With the inspector still open refresh the page on your computer (command + R)
Somehow the Webapp cache got cleared and i got the non-cached code.
I found a a work-around. Just put a link on the web page itself for users who are having trouble seeing new version...
refresh
It works just like the iPhone/iPad refresh button on the address bar!
First plug the phone into the computer then open the web app on the phone and Safari on the computer, then you can open the web inspector in Safari from the menu "Develop>Name of phone>title of app" (if you can't see the develop menu you can turn it on in Safari's preferences).
From there you can see/edit the cookies and local storage just like sites on your computer and pressing command+r while the inspector is focused will reload the app on the phone.
You can connect your device and open Safari's web inspector on your computer and run document.location.reload() in the console tab to reload the page.
Before reloading you can press Option+Command+E to make sure the cache is cleared.
Instead of above you can also press Shift+Command+R to reload the page without cache but sometimes it hasn't worked for me.
Try appending a unique GET tag to the ends of any and all href attributes, for example:
<link rel="stylesheet" type="text/css" href="/css/global.css?
<?php echo(mt_rand(10000000, 99999999)); ?>
" />
This would generate href="/css/global.css?########", with a different number nearly every time. This forces iOS' Safari to pull the "new" page down, as there is no data in its cache originating from the same URI, and there likely never will be (unless you plan on reloading the app millions of times during development :D )
If the iOS6 device has a jailbreak applied, you can use ssh to delete the content of the folder "/private/var/mobile/Library/Caches/com.apple.webapp".
Next time that you start the web app, all files will be re-downloaded from the webserver.
The only way to deal with this currently is to wait, but there is a workaround. If you change the name of the file, it will pull the new code. However, if you change it back to the old name before the cache clears, the old code will be used. The cache refreshes periodically and will update eventually. I just had this happen to me with a CSS file that refused to change. Time will fix it, but if you just need it to update for testing, a name change will work.
This drove me nuts for a while. Tried clearing the cache on device - no luck. Renaming the page did help, but once you rename it back, you still get the same stale version.
Found the solution yesterday. You need to connect your device to Mac and open Web Inspector in Safari Develop menu. Once in Web Inspector, simply press "Reload page" button on the Inspector's toolbar and - voila - you see the fresh version on your device's screen.
Just set the request you pass to the webview to NSURLRequestReloadIgnoringLocalCacheData
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
[self.webView loadRequest:request];

Facing Error in running ripple emulator (Chrome extension) for app testing?

When i just enable a html file from my pc to emulate.It just shows :--
"Looks like what we have here is a failure to... emulate
You're seeing this window because it looks like the zombie apocalypse has started.
"It says Hit or fire" ""
http://i.stack.imgur.com/1ABj4.png
It is working few days for me..But now i started opening it i got an error. My Ram is 2Gb and supports full requirements..
Please help me out.
That message means Ripple is waiting for something to finish, and has decided to show a warning rather than hanging. You can CTRL+I to open web inspector and see if there are any console messages that help explain what failed.
You can hit the FIRE button to clear all cached settings. This will reset Ripple to its initial state (Ripple stores all user settings in localStorage - hitting the FIRE button clears this localStorage data). If a cached setting was the reason for the "red screen of death", then you will see the black "welcome to Ripple" screen after hitting the FIRE button.
Otherwise, I'd suggest disabling and re-enabling Ripple.
Finally as a last resort, make sure to update to the latest version of Ripple using the *.crx file available here: https://developer.blackberry.com/html5/download/
if you are trying to access something in your local file system i found the problem
https://github.com/blackberry/Ripple-UI/issues/565
since you're running in the file:/// scheme, you need to get around
the browser's security a little bit. Do the following:
in chrome://chrome/extensions/ make sure the "Allow access to file URLs" is checked for Ripple (might have to go into developer mode to do that, check box on the top right of the page)
quit chrome and restart it with --allow-file-access-from-files flag
doing this resolved the problem for me.
you can check with this page github.com/blackberry/WebWorks-Samples/tree/master/HelloWorld

Resources