Debugging JavaScript code in iOS simulator using Safari - javascript

I am building an iOS app in which I have a webView i.e. UIWebView not WkWebView and I have some JavaScript code that uses AngularJS for UI manipulation.
I run my app in the iOS simulator from Xcode and then open Safari and go to Develop -> iOS Simulator -> AppName -> index.html, which attaches the safari web inspector to the web view. In the inspector under the resources tab I select the relevant JavaScript file and put a breakpoint for the JavaScript code that I want to start from.
What happens now is when I navigate to the part of my app when the JavaScript code is executed, it pauses in the web inspector just fine. The problem is, I cannot navigate through the code: it just freezes. I cannot unpause it.
What I do notice in my Xcode console is this error
Multiple locks on web thread not allowed! Please file a bug. Crashing now...
This doesn't happen all the time, just 60-70% of the time when I am working on my app. So this is my first iOS app and I am building it using Swift.
This seems like I have a missing link somewhere. But any tips or anything would be great.

Related

React Native: Prevent remote debugger from opening in Chrome

I've written a Bash script to open React Native Debugger (desktop app) before running my iOS emulator itself. By default my iOS emulator has "Remote JS Debugging" on, and when the emulator starts up, it opens the remote JS debugger in Chrome. So I end up with React Native Debugger and the Chrome remote JS debugger both open, and these conflict with each other and sometimes cause the app to crash.
My question is: is there a way to prevent the iOS emulator from automatically opening the remote JS debugger in Chrome?
Thanks!
You could try setting the REACT_DEBUGGER env variable to some failing path, so it will fail behind the scenes when trying to open it.

Android Native/Stock/Default Browser Won't load my React Web App

So my react web application loads perfectly fine on Android Chrome Browser, and other browsers such as UC Browser, Safari on iOS.
However, recently we found that the web application loads blank page when opened using Android Native/Stock/Default Browser ( The blue globe icon ) found on any Samsung / Lenovo devices.
I was able to use weinre / ngrok to attach web debugger, but I was not able to find any errors. The browser would just stop requesting for more static assets and stop doing anything.
I ran another test for my internal web application which is also a react web app (same config), and it loads fine on Android Native/Stock/Default Browser. I'm looking for clue as to what may cause this browser to stop requesting from the webserver...
Thx

How to debug JavaScript in IOS Action App Extension?

With iOS, Action App Extension, one could run a JavaScript code against HTML. However, after quite some search on Google, I have not found any document explaining how to debug in this situation (insert a break point or simply add/view console out statement).
It's not too hard, although recently I've had an issue with the page showing up when connected to the simulator. In that case I just ended up using my phone directly. (Apparently you need to start desktop Safari after the iOS Simulator has started to inspect "remote" Simulator sessions)
Ensure that on the device Settings->Safari->Advanced->Web Inspector is on
(Make sure you've Trusted the computer from the device)
Start MobileSafari on your device by running from Xcode and choosing Safari
-- this isn't necessary but you can decode the iOS Objective-C/Swift code as well. You can just start MobileSafari manually and it will be visible in desktop Safari.
Start Safari on your desktop, make sure Show Develop menu in menu bar is on in Preferences.
In the Develop menu you will see your device name, say 'BSharer's iPhone'
select the page name underneath your device name, say 'en.m.wikipedia.org - Wikipedia'.
You are now debugging that device page on your desktop.
There are options to 'Automatically start debugger etc...', but I've found that when I tried these my code would not execute.
You can't place debugger statements in the app extension JavaScript as it isn't injected until your App Extension starts. Instead I would add a debugger; statement to my app extension JavaScript code which will pause the debugger in the app extension JavaScript code at the debugger; statement.
Start your app extension by selecting it in the Share menu, set any other breakpoints you are interested in, then hit the continue button on the debugger.
You will also catch uncaught exceptions of course.
The official documentation for this is here.
Make sure you remove the debugger; line from production code.

How do I launch a standalone web app from mobile safari using javascript?

I am developing a standalone web app that installs on iphone homescreen.
It has a calendar function that the user can download an *.ics file directly into the iphone.
However, that cannot be done from within the standalone web app, so I have a punch out url to mobile safari so that it will work.
All that works fine...
However, after the ics file is loaded into the calendar and closed, it returns to the mobile safari page where I in turn close that by using onclick='self.close()'. That works fine too...
After that page closes I want to then launch back into standalone app so the user is returned to where they were...
How do I launch my own web app from a mobile safari javascript code?
All the searching shows me how to go from standalone to mobile safari,...I want mobile safari to standalone.
I have seen the windows.location="myapp://myparam" but cannot find proper syntax to get it to work.
What is the syntax for this?
Any other solution is well received too...will need to find Android solution too, but it is not as crucial...
Thanks

Remote debugging javascript on iPad from a Windows machine possible?

I have an iPad with iOS 6.1 connected to a windows 8 machine. I would like to be able to debug some javascript code running on the iPad.
The safari on iPad has a web inspect option that needs the iPad to be connected by wire to computer and then can be accessed in Safari for desktop's develop menu. I installed Safari 5 for Windows but don't see the iPad detected in the develop menu.
Any other ideas ?
The Firefox Tools Adaptor allows one to use Firefox DevTools for Safari on iOS.
https://github.com/mozilla/valence#debugging-safari-firefox-and-other-webviews-on-ios
For remote debuggin I use Weinre.
Weinre has almost everything you need, but lacks a JavaScript debugger.
It has a WebInspector for DOM manipulations, network traffic, timeline, resources and a console.
Checkout this project on GitHub: weinre-remote-debug to setup weinre locally.
Another option described on this page is jsconsole.com. By appending a <script> tag to your page (or running a bookmarklet on your device) you get access to a JS console.
To start, go to jsconsole.com and run :listen in the prompt. This will give you a unique session ID and a script tag that you insert into your mobile web page.
Now, any console output that your mobile page generates will be streamed to the console open in your desktop web browser, including any errors!
It is certainly no replacement for a full web inspector, but it can get you out of trouble when you don’t have access to a Mac.
Source: https://blog.idrsolutions.com/2015/02/remote-debugging-ios-safari-on-os-x-windows-and-linux/

Categories

Resources