What debugging techniques do you use for iPhone/iPod web development? - iphone

I'm working on a web application, and we are targeting the iPhone and iPod Touch. I'm familiar with the debugging tools for FireFox and IE (e.g. Firebug and IE Developer Toolbar), but I can't find anything for the iPod. I am not looking forward to using alert as my main debugging tool, especially when I expect mouse events to be one of the major issues.
Is this really the state of the art? What tools do you recommend?
Also, how similar is the html layout on an iPhone to that of Safari running on Windows? On a Mac?

The iPhone version of Safari includes a debug console that can be very handy. Settings > Safarai > Developer.
You can also use the Simulator in the iPhone SDK. There's no extra debugging, but it's easier than using a physical device all the time.
You can also use the desktop version of Safari for many things.

The web tools that target the iPod Touch and iPhone arenas include
[iPhone Remote Debug Console](
http://code.google.com/p/iphonedebug/)
BlackBaud Simulator for Windows
[MobileSafari Simulator](
http://www.testiphone.com/)
[iPhoney](
http://marketcircle.com/iphoney/)

While WebKit has a remote inspector, it is hard to enable on an actual iOS device (at least without jailbreak) and so most tools for it are simulator-only. iWebInspector looks promising for this, but keep in mind the simulator's WebKit library is not identical to the device's.
That's where weinre comes in. With weinre, you can "debug a web page displayed on your phone from your laptop". How it works is you run its custom HTTP server that hosts two things:
a JavaScript file you include on the page you want to debug
an Inspector page that you load on the machine you want to debug from
You start the server e.g. java -jar Downloads/weinre.jar --boundHost -all- --httpPort 4242 and then put a script tag like <script src="http://weinre-server-name.local:4242/target/target-script-min.js"> in the source code for your webpage and load the inspector by navigating to e.g. http://weinre-server-name.local:4242/client. When you load the target page on an iPhone on your local WiFi connection, the connection will show up in the client page on your mainframe and you can use the Inspector tabs to view/edit the page on the iPhone.
It has some limitations (no Javascript breakpoints and such) and can be a little laggy, but overall it's pretty magic.

There is also a nice tool called iWebInspector
http://www.iwebinspector.com/

Related

How can you test conditional CSS meant for an iPhone on a desktop browser like safari, chrome, or firefox?

Specifically, the "max-device-width:" condition
If you're on a Mac, you can use the iPhone simulator that comes with XCode. I've also used a Firefox add-on called "Modify Headers" and I send iPhone headers, however, that may not help much with max-device-width.
For mac or PC, if you can upload your files to any temporary server, you can check the results online in TestiPhone: http://www.testiphone.com/
This is a web browser based simulator for quickly testing your iPhone
web applications. This tool has been so far tested and working using
Internet Explorer 7, FireFox 2 and Safari 3.
The firefox plugin Developer toolbar let you change the browser size with just one click to the device size. I bet there is plugins like that to the other browsers. If you can't find that to all browsers then I suggest that you just upload your code to a server and surf to it using an iPhone.

Develop a website for an iPhone without having iPhone/Mac

I need to develop a website which will be used exclusively on iPhone and iPad. I don't have those devices, neither do I have a Mac.
What are the possible free solutions for me to be able to test the website during development?
The most obvious one would be to use an iPhone SDK, but since it costs $100/year but since it is available only for Mac, it is not a solution in my case.
Download Safari 5 for Windows, enable the Developer Menu features and change the User Agent to Mobile Safari iPad or Mobile Safari iPhone. This will let you see how your website looks when an iPad or iPhone renders it. Just make the window smaller to get the full experience.
If analyst predictions are right, there will soon likely be an abundance of iPhone 3G devices on eBay as lots of people are eligible to upgrade to iPhone 4 tomorrow. Picking up a cheap 3G may be the best solution to your testing requirements.
Or you can test it out at an Apple Store if your website is accessible over the internet or available on a laptop with an ad-hoc WiFi connection.
You can test your website in any browser, but yes, mobile browser probably behave different at some points.
If you cannot find a mobile web browser simulator for iPhone than the "cheapest" alternative would probably be an iPod touch.
Update:
You might want to have a look at iBBDemo:
iBBDemo2 - Cross Platform iPad and iPhone Simulator
You could try using something like:
www.testiphone.com/
Recommend you use jsconsole
Remotely debug a mobile web app
jsconsole.com is a simple JavaScript command line tool. However, it also provides the ability to bridge across to other browser windows to remotely control and debug that window - be it in another browser or another device altogether.
In fact, mobile web app debugging is so damn tricky, that I gave up, and decided to build this very tool instead. See the videos examples if you'd rather see this in action now.
Creating a session
To create a new session, in the jsconsole prompt, simply run:
:listen
This will yield a unique key along the lines of FAE031CD-74A0-46D3-AE36-757BAB262BEA. Now using this unique key, include a anywhere in the web app that you wish to debug:
<script src="http://jsconsole.com/remote.js?FAE031CD-74A0-46D3-AE36-757BAB262BEA"></script>
Now any calls to console.log from your web app will display the result in the jsconsole session that is listening to your key. Equally, if you run a command in the jsconsole session, the code will injected in to your web app and the result returned to jsconsole.
In addition to generating a new code with :listen, you can also ask jsconsole to listen to a predefined code (but for your own security, try to chose something unique that only you know):
:listen FAE031CD-74A0-46D3-AE36-757BAB262BEA
Now I can use the same remote key in my web app to avoid having to regenerate a new code each time. Note that only the last remote client (i.e. your web app) to connect to jsconsole will recieve remote debug calls - previous windows will be ignored.
To know when the web app has connected, jsconsole will notify you by showing your the userAgent string for the device:
:listen FAE031CD-74A0-46D3-AE36-757BAB262BEA
Creating connection...
Connected to "FAE031CD-74A0-46D3-AE36-757BAB262BEA"
Connection established with Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-GB; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8
A word of warning
Note that this technique is also injecting code directly in to your web app - this tool should only be used for debugging. I can't take respibility for how you use this tool, basically: take care!
Current known support
Remote debugging has been developed to work on all platforms, even if the technology isn't supported. However, jsconsole remote debugging has specifically tested and working on the follow mobile devices (feel free to add to this list):
iOS 4.2.x - iPad, iPhone 4
Andriod 2.2.2 - Nexus One
webOS - Palm Pre
There are some Video examples too
More detailed information please see this links:
http://jsconsole.com/remote-debugging.html
There are some obvious things here:
1)Work very hard to make your site work on all major browsers - including Safari and any other mobile devices other than iPad... this will let you make sure it works on smaller screens well.
2)Read up on known glitches in these browsers and see if you can avoid them.
3)Whenever you are with friends showing off their iPad, or who have an iPhone, ask to test your site on it.
I need to develop a website which will be used exclusively on iPhone and iPad
This seems a bad idea. if it's only used on iPad/iPhone, surely you should write an App and get all the benefits of UI, etc.
Websites should not be tied to specific devices.
This is not 1998 : Best viewed in I.E. In fact your suggestion is worse than that.
If you really want a website that only works on those devices then you'll need to check the user-agent string, but otherwise html is html and unlike what Apple may want you to believe, works just as well on Symbian, Blackberry, Android, S40, Windows, Windows Mobile, etc etc..
(In fact, it works better on Symbian as Symbian actually supports Flash.)

Webrowser which emulates the iPhone browser

On the Mac I got the iPhone Simulator but under Windows and Linux enviroments I need a webbrowser which emulates the behaviour and size of the iPhone browser. I'm not looking for a website with a frame with the iPhone screen size but an actual application. Prefably webkit based so it will behave as much like the iPhone as possible. It should also be able to send the same browser headers as MobileSafari in the iPhone and if not it should be possible to modify the headers. That could be done in a menu in the program, support plugins(which have the power to modify headers) or the progam should be opensource.
It might not exist and if not thanks anyway. However if it does that would be awesome. If you know a program which have some of the mentioned features but not all of them an no one have posted a better one feel free to post a link/the name of that browser (still better then nothing or a framed site in Safari).
tldr: iPhone like browser, same window size and headers as MobileSafari.
Try one of the following:
Blackbaud iPhone Browser Simulator
iPhone Drift web browser for Windows
MobiOne iPhone and Palm Pre emulator
So far as I can see, only the first of these actually uses Safari as the rendering engine, and it is using Safari for Windows rather than Mobile Safari, but it should be close enough I think.
try iphonedrift on windows

Best browser for testing under Safari Mobile on Linux?

I have an iPhone web app I'm producing on a Linux machine. What's the best browser I can use to most closely mimic the feature-limited version of Safari present on the iPhone? (It's a "slimmed down" version of WebKit, which is more limited than one might think.)
A used iPod Touch for US$150 (used, in Seattle). It's either that, or the iPhone simulator running on a Mac. If one is specifically targeting "iPhone web app", the cost should be budgeted into the project.
Barring that, use desktop Safari. That will still require a Windows or Mac box. The rendering engine is the same, so I imagine it's as close as you're going to get on the desktop.
On the other hand, what are the problems you are trying to avoid? Mobile Safari is pretty good at rendering most web sites I call up. There are guidelines for development, and avoid media such as Flash. If you don't have the hardware, borrow it for sanity checking when you're done. That's the route I'd go if I absolutely didn't want to spend the US$150.

Is there a way to test a web site on the iPhone without an iPhone?

I want to test a website to see how it works with the iPhone but I don't own an iPhone or an iPod touch. Is there a way I can test how the site works on them without owning one?
What I'm really after is fixing how Stackoverflow's WMD markdown editor works on the iPhone. I hear that the hyperlink and image prompts are created too high. I think I know how to fix that but it's pretty tough to develop blind.
If you own a Mac, you can download the iPhone SDK which comes with an iPhone simulator. It works not only for debugging a native app but also for browsing the web.
If you have Safari on your computer, you can enable the "Develop" menu under Preferences > Advanced > Show Develop Menu in Menu Bar.
With this enabled, you can go to Develop > User Agent, and change the user-agent string to the device you want your browser to report to the web server as.
By resizing the window to the appropriate width, you can emulate what the site will look like on the iPhone.
The upside of this is that it's quick, it works on both Windows and Mac, and you don't need the iPhone SDK installed. You can also browse iPhone-specific versions of websites that catch user-agent strings directly from your PC.
The downside is obviously your Safari browser on your PC will behave quicker than on the actual device (especially in regard to javascript performance); it displays plugins and shows fonts that may not be available on the actual iPhone OS; a lack of multi-touch support and "snapping" to columns while scrolling; no auto-rotation; no multi-touch/pinch-zoom; widgets will look different; etc.
Just a notice on this old thread - we have now enabled live testing on iPhones and iPads via vnc at CrossBrowserTesting.com.
Ken - Founder
There is a free app on the mac that emulates the iPhone browser: iPhoney
I don't purport to have done more than a web search, but the problem seems to be solved by several products that are "iPhone web app emulators."
http://www.testiphone.com/
http://marketcircle.com/iphoney/