Viewing Console.log in ios simulator - ios

Please excuse my silliness. I feel as this should be a simple problem. I am using phonegap to develop in IOS. I am wondering how come console.debug does not show up in the xcode console. How can I view any javascript error or exception in xcode console or anywhere? I am running on 4.3 IOS IPAD simulator. Thanks.

You can watch the console.log with a safari-browser. Open the ios-simulator or connect the ipad by usb. Open safari and take a look in the menu "developer". Choose your web-site and the web-inspector will open.
more info here:
https://developer.apple.com/library/ios/documentation/AppleApplications/Reference/SafariWebContent/DebuggingSafarioniPhoneContent/DebuggingSafarioniPhoneContent.html

As far as I know, you cannot. I have solved this problem by using jsconsole.com. It allows you to output console message (and much more) by simply adding a script tag to your app.
NOTE: for debug use only.

Just to clarify the old answer from Fischel, here is the menu on a desktop Safari that allows you to connect development tools to simulators or devices.

Related

Firebase - iOS App Installation on iPhone X is not working

I uploaded an iOS enterprise build using App-Distribution feature of Firebase Console and shared with my testers.
We are able to download it on all devices except on iPhone X. The error shows "os version not supported". On click of this error, it displays details that "The developer needs to upload a build that supports iOS 10.15". Please check screenshots for reference.
Please note that iPhone X have iOS 13.3. I suspect not be an iOS version issue, because I downloaded app on my personal iPhone XR which has iOS 13.3.
Safari Browser Desktop mode was the culprit. If turned on, any distribution provider's script will think the link was opened it mac instead of iOS.
No need to reset the phone in my case!!!
Edit:
Actually Ram's answer works
Go into settings
Safari
Request Desktop Website
Turn off the switch
Old:
For me erasing all content and settings worked.
Steps:
open Settings
go to General
Reset (at the bottom)
Erase All Content and Settings
Remember to do some backup of your data because it will erase all the content.
I didn't check if Reset All Settings option works.
I hope it will help you!

iPad Safari Web Inspector crashing on page load

I have a video focused website made in wordpress. When we go to test the website on iPad we connect it to a mac laptop and open the safari developer tools to check if we have any errors and whatnot. Everything works on our homepage but when we go to any video post we have added, it crashes the developer tools window, and the browser on the iPad has a little drop down at the top saying "A problem occurred with this webpage so it was reloaded".
The page is fine on the iPad, there aren't any PHP errors in our logs, everything works fine functionally, so I can't figure out what is crashing it.
Any ideas? Any way I can troubleshoot this?
Thanks in advance :) And let me know if you need any more information!
I had this exact problem and solved it by updating both OSX Safari and the iPad to the latest versions. Now i can use the Web Inspector again.

phonegap iOS app working on simulator but not in device. How to debug

I just finished developing a Cordova / Phonegapp app. When I test it on iOS simulator it all works fine and quick, but, when testing on device it works only part of it.
My app is a game with the kingdom background and has 8 buttons (8 buildings).
When I click on each building it leads me to a screen representing what it's inside the building, but one of them doesn't work and gets my app frozen.
How can I see fail or crash reports that helps me debug my app on device?
If you provide full path to your file i.e. "file:///Users/.../someDir/some.html" it will work only on simulator running on the same machine where your project is.
I suggest just adding the additional path to the file you want to access i.e. if you are in "/someDir" you will need to provide only "some.html" or if you want to access parent directory just use "../".
As far as debugging Cordova app, I suggest downloading this plugin and using console.log instead of alert.
Hope this helped.
Ok, I found a "spartan" way to debug my app via alert and found that an url wasn't set properly (still don't know why it worked on simulator)

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 - removed console log for IPad - how to use web inspector on windows?

So iOS6 is out, horrah. Now, it appears as though Apple have removed the 'Developer Console' that used to exist in Safari. Great, I hear a lot of people say - it was limited.
But, it works on the device - now apparently you have to connect the device to a Mac to get web inspector?
Is this the only way of debugging with console? Is there a way of debugging with windows, safari? Please note, I don't mean just changing user-agent, which you can do on Safari Windows - that doesn't register touch events - just click.
If you don't have Mac OSX you can use this script as console replacement:
https://github.com/robotnic/waterbug
It shows error message, it's possible to log all kind of variables, you have to turn your iPhone or iPad 90° to the right to open the console.
A poor mans debugging console:
try {
var test = document.do.something();
}
catch (exc) {
alert(exc);
}
One can debug on the device by using bookmarklets (especially within Mobile Safari).
Debugging on the device can be very important if an error only appears live on the device but nowhere else. There is a variety of bookmarklets for developer, so choose the tool of your choice (e.g. Firebug Lite), add it to your bookmarks and use it right where you need it.
This may not be the Developer Console, but it is a method to debug much more accurate and job-oriented.
I wrote a blogpost on how to use bookmarklets on my weblog (there is also a list of other common testing tools and further bookmarklets):
http://hofmannsven.com/2013/laboratory/ios-bookmarklets/
UPDATE: Chrome released its Mobile DevTools which will make debugging (within Google Chome Mobile, Android Devices only) much easier. This will not fix the missing DevTools issue within Safari, but it might help to locate errors on a device:
https://developer.chrome.com/devtools/docs/remote-debugging
http://www.html5rocks.com/en/tutorials/developertools/mobile/
UPDATE2: Mozilla released a Firefox add-on to enable web development across browsers and devices: http://youtu.be/kEFbQwB81RE?t=1m58s
Have a look for weinre. It allows you to inspect a page running in Safari from another computer using a Chrome-like web inspector
You can use window.onerror to debug errors without a console. Simply add this code to your HTML document in its own <script> tag before any other Javascript code:
<script type="text/javascript">
window.onerror = function(e){
alert(e);
};
</script>
This will do so that whenever there is an error, the error message will be shown in an alert dialog box, which is visible in iOS Safari. It's important that the above code runs before the error you're trying to debug, and if you're debugging a syntax error, it's also important that it's in a separate <script> tag.
Instead of Safari on Windows you could use an app by Telerik called AppBuilder. I've found the instructions on this blog. You'll need to get an account to use the Telerik Platform though.
This will give you dev tools like the ones in Safari. I've used it on Win7 64 bit with regular web apps and Phonegap apps running on an iPad with iOS 7.1.
Like neno suggested, Telerik AppBuilder is a great applications. I am actually running Windows XP in a virtual machine on Linux only for the purpose of debugging my iPhone. Windows XP because in my case Windows 7 does regognize the iPhone, but iTunes and Telerik AppBuilder don't.
Looks like the built in console is gone. I tried plugging into a Windows 7 and opened Safari and could not locate the developer console. Then I read this article which confirmed it.
If you need to be able to test your site in both orientations then waterbug is not a good option, because it uses up the landscape orientation for its console view.
One decent option is to use Adobe Edge Inspect. You open your site on Chrome and open the app on your device and your device will mirror whatever page you have open on your desktop. Then you can use the Chrome dev tools to debug your content.

Resources