Developing Apps with PhoneGap CLI developing-apps-with-phonegap-cli
At any given time, as a developer you can run your app on a device or within a emulator, provided you鈥檝e configured your development environment.
In order to run the following examples you will need a system that runs OSx (Mac) with Xcode, or a Mac/Win/Linux system with the Android SDK installed.
Bootstrap your development environment bootstrap-your-development-environment
For iOS: To develop for iPhones and iPads, you need Apple鈥檚 Xcode IDE.
- Download it for free .
For Android: To develop for iPhones and iPads, you need Google鈥檚 Android Stuido IDE.
- Download it for free .
Download the Source download-the-source
Once you鈥檝e successfully boostrapped your development environment, download the source from the AEM App Build Tile:
- Click on the PhoneGap Build tile dropdown chevron.
- Click Download Source.
- Select the desired source from the Download Source modal.
- Click Download and save save the ZIP to your machine.
- Extract the downloaded zip file to your workspace.
Build and load the App (from source) build-and-load-the-app-from-source
PhoneGap CLI can create a platform project, compile the source, and deploy the app in a single command.
- Make sure you鈥檝e Installed PhoneGap CLI, see above.
- In a console (or terminal) window, navigate to the root directory of your extracted source.
- Enter the following command:
phonegap run android
// -- or -- //
phonegap run ios
- Create a new folder (mkdir test)
- Navigate into this new folder (cd test)
- Run 鈥榩honegap create helloWorld鈥
- Navigate into helloWorld (cd helloWorld)
- Run 'phonegap run android (or replace android with ios as above).
- Emulator wil open running your newly created PhoneGap App, saying 鈥楧evice Ready鈥 if the JavaScript bridge to native is operational.
Debug Javascripts with Safari and IOS debug debug-javascripts-with-safari-and-ios-debug
You can debug your app鈥檚 JavaScripts using Safari鈥檚 developer tools, the same way you would with a web application.
Enable Safari Developer Tools enable-safari-developer-tools
To enable the developer tools:
-
Open Safari鈥檚 preferences
- Click Safari in menu bar
- Click Preferences
-
Click Advanced in Preference window
- Check 鈥淪how Develop menu in menu bar鈥
- Close the Preference window
Connect Safari to iOS connect-safari-to-ios
You can connect Safari to either an iOS device or emulator.
- In a console window, navigate to the root directory of your extracted source.
- Enter the following command to launch your app on your device or emulator.
phonegap run <platform> --device
// -- or -- //
phonegap run <platform> --emulator
- Open Safari
- Click Develop in the menu bar
- Select iOS Simulator sub menu
- Click on home.html
Debug JavaScript with Safari鈥檚 Web Inspector debug-javascript-with-safari-s-web-inspector
You can set breakpoints anywhere in your source. When you interact with your emulator or device, the execution of your app will stop at those breakpoints. You can step trough the execution and inspect the values in variables.
- Click Resources in the Web Inspector window
- Navigate the source tree and click on desired source file
- Click on the line number adjacent to add a breakpoint
- Interact with device or emulator
- Use the control buttons to continue execution, step over, step into and step out of methods:
The Next Steps the-next-steps
Once you have learnt about Developing Apps with PhoneGap CLI, see Accessing Device Features.