Transcript
Page 1: Phonegap Development & Debugging

LABLABPhoneGap

Development & DebuggingIvano MalavoltaIvano Malavolta

[email protected]

http://www.di.univaq.it/malavolta

Page 2: Phonegap Development & Debugging

Roadmap

• My Development Environment• My Development Environment

• Debugging PhoneGap Apps

Page 3: Phonegap Development & Debugging

Development Environment

• Sublime Text 2Sublime Text 2Sublime Text 2Sublime Text 2– http://www.sublimetext.com– http://www.sublimetext.com

• SublimeTextSublimeTextSublimeTextSublimeText Package Package Package Package ControlControlControlControl– http://wbond.net/sublime_packages/package_control

• HTML HTML HTML HTML PrettifyPrettifyPrettifyPrettifyHTML HTML HTML HTML PrettifyPrettifyPrettifyPrettify– https://github.com/victorporof/Sublime-HTMLPrettify

• JSHintJSHintJSHintJSHint– http://www.jshint.com/

Page 4: Phonegap Development & Debugging

Roadmap

• My Development Environment• My Development Environment

• Debugging PhoneGap Apps

Page 5: Phonegap Development & Debugging

My testing/debugging process

1. Code & test in the Desktop browserDesktop browserDesktop browserDesktop browser– This works for functionalities not relying on – This works for functionalities not relying on

PhoneGap– You may use PhoneGap shimmers here

2. Run in the simulatorsimulatorsimulatorsimulator & test in the Desktop browser

– Very handy & accurate– Very handy & accurate

3. Run on the devicedevicedevicedevice & debug in the Desktop browser

– Complete control & confidence

Page 6: Phonegap Development & Debugging

Desktop Browser

+ very quickquickquickquick+ very handyhandyhandyhandy functions+ very handyhandyhandyhandy functions

see Chrome’s Web Development Tools+ directdirectdirectdirect+ BreakpointsBreakpointsBreakpointsBreakpoints

- cannot test useruseruseruser agentagentagentagent’s metadata- browsers’ small differencesdifferencesdifferencesdifferences and bugs- browsers’ small differencesdifferencesdifferencesdifferences and bugs- cannot test all PhoneGapPhoneGapPhoneGapPhoneGap’s specific functionalities

- you need PhoneGap shims

Page 7: Phonegap Development & Debugging

Chrome Security Restriction

If you need to test your JSON calls from a locallocallocallocal web app, you need to relax Chrome’s security policies withrespect to local files access and cross-domain app, you need to relax Chrome’s security policies withrespect to local files access and cross-domain resources access

OSXOSXOSXOSXopen -a Google\ Chrome.app --args “

--disable-web-security“

WindowsWindowsWindowsWindowschrome.exe --disable-web-security

DO IT ONLY FOR DEBUGGING!!!

Page 8: Phonegap Development & Debugging

Desktop Browser - Tools

PhoneGap Shims– PhoneGap-Desktop– PhoneGap-Desktop

https://github.com/jxp/phonegap-desktop/wiki

– stopgap https://github.com/alunny/stopgap

– pgDebughttps://gist.github.com/476358

Browser’s extension for window dimensionsBrowser’s extension for window dimensions– Window Resizer

https://chrome.google.com/webstore/detail/kkelicaakdanhinjdeammmilcgefonfh

Page 9: Phonegap Development & Debugging

PhoneGap Desktop

1. Choose a webkit browser1. Choose a webkit browser

2. Copy debugdata.json into the root www folder of your app’s project

3. Use phonegap-desktop.js in place of the standard phonegap library

4. modify to your specific needs4. modify debugdata.json to your specific needs

Page 10: Phonegap Development & Debugging

Desktop Browser - Tools

RippleRippleRippleRipplehttp://ripple.tinyhippos.com/http://ripple.tinyhippos.com/

Page 11: Phonegap Development & Debugging

Simulator

+ you use the devicedevicedevicedevice’s browser’s browser’s browser’s browser+ very handyhandyhandyhandy functions+ very handyhandyhandyhandy functions

+ see Chrome’s Web Development Tools+ ddddirectirectirectirect+ breakpointsbreakpointsbreakpointsbreakpoints

- ddddeviceeviceeviceevice’s performance ’s performance ’s performance ’s performance is not consideredthis is iOS-specific

- pppperformanceserformanceserformanceserformances may be biased- pppperformanceserformanceserformanceserformances may be biasedusually you need some kind of hook within your app

- devicedevicedevicedevice’s ’s ’s ’s capabilitiescapabilitiescapabilitiescapabilities are only simulated

Page 12: Phonegap Development & Debugging

Simulator - Tools

iWebInspectorhttp://www.iwebinspector.comhttp://www.iwebinspector.com

It is based on an hidden debugging feature from Apple

Page 13: Phonegap Development & Debugging

on Device

+ accurateaccurateaccurateaccurate+ still handyhandyhandyhandy+ still handyhandyhandyhandy+ accurate performance accurate performance accurate performance accurate performance tests+ aaaaccurate browserccurate browserccurate browserccurate browser’s tests

- You need to deploydeploydeploydeploy the app to a real device- You need to deploydeploydeploydeploy the app to a real device- No breakpointsbreakpointsbreakpointsbreakpoints

Page 14: Phonegap Development & Debugging

onDevice - Tools

WeinreWeinreWeinreWeinre

http://people.apache.org/~pmuellr/weinre/docs/latest/

3 3 3 3 mainmainmainmain componentscomponentscomponentscomponents: : : :

• DebugDebugDebugDebug ServerServerServerServer: the HTTP server that’s used by the Debug Client and Debug TargetDebug Client and Debug Target

• DebugDebugDebugDebug ClientClientClientClient: the Web Inspector user interface

• DebugDebugDebugDebug TargetTargetTargetTarget: the (web) app you are debugging

Page 15: Phonegap Development & Debugging

Weinre Architecture

http://bit.ly/IK9kvC

Page 16: Phonegap Development & Debugging

Reference Table

PGPGPGPG----DesktopDesktopDesktopDesktop RippleRippleRippleRipple iWebInspectoriWebInspectoriWebInspectoriWebInspector WeinreWeinreWeinreWeinre The The The The CraftsmanCraftsmanCraftsmanCraftsman waywaywayway

iOSiOSiOSiOS

AndroidAndroidAndroidAndroid

craftsmancraftsmancraftsmancraftsman waywaywayway: console.log() + alert()craftsmancraftsmancraftsmancraftsman waywaywayway: console.log() + alert()

Page 17: Phonegap Development & Debugging

Bonus

if you are developing web apps on multiple devices you can use Adobe Adobe Adobe Adobe ShadowShadowShadowShadowdevices you can use Adobe Adobe Adobe Adobe ShadowShadowShadowShadow

http://labs.adobe.com/technologies/shadow/

Page 18: Phonegap Development & Debugging

Adobe Shadow

Page 19: Phonegap Development & Debugging

.. A final consideration

… these are MYMYMYMY development environment and the debugging tools IIII usethe debugging tools IIII use

Consider them as a starting point

& feel free to use others


Top Related