Skip to content

Instantly share code, notes, and snippets.

@szabacsik
Last active August 20, 2019 09:40
Show Gist options
  • Save szabacsik/52ea3b8c06fcdbe7cd9a68d768634619 to your computer and use it in GitHub Desktop.
Save szabacsik/52ea3b8c06fcdbe7cd9a68d768634619 to your computer and use it in GitHub Desktop.
Apache Cordova / PhoneGap Quick Start Guide

Apache Cordova / PhoneGap Quick Start Guide

Create Mobile apps with HTML, CSS & JS ( bootstrap, jquery )

npm install -g cordova
mkdir myCordovaProject && cd myCordovaProject
touch .gitignore && nano .gitignore
.idea/
node_modules
touch .gitattributes && nano .gitattributes
* text=auto eol=lf
touch README.md
git init
git add .
git commit -m "Initial commit"
cordova create cordovaExample com.example.app Example

Change the description and the author in the following files:

nano .\cordovaExample\package.json
nano .\cordovaExample\config.xml

Add target platforms

cd cordovaExample\
cordova platform add android
cordova platform add browser
git add .
git commit -m "Add android and browser platform"

Add Bootstrap, Jquery ( or any other css or javascript library )

mkdir www\vendor -p
cd .\www\vendor\
curl -sSL https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/js/bootstrap.bundle.min.js --output bootstrap.bundle.min.js
curl -sSL https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/js/bootstrap.bundle.min.js.map --output bootstrap.bundle.min.js.map
curl -sSL https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/css/bootstrap.min.css --output bootstrap.min.css
curl -sSL https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/css/bootstrap.min.css.map --output bootstrap.min.css.map
curl -sSL https://code.jquery.com/jquery-3.4.1.min.js --output jquery-3.4.1.min.js
cd ..
nano index.html
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width, shrink-to-fit=no">
        <title>Example</title>
        <link rel="stylesheet" type="text/css" href="vendor/bootstrap.min.css" />
    </head>
    <body>
        <nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
            <a class="navbar-brand" href="#">App</a>
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarText" aria-controls="navbarText" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarText">
                <ul class="navbar-nav mr-auto">
                    <li class="nav-item active">
                        <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="#">Lorem</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="#">Ipsum</a>
                    </li>
                </ul>
            </div>
        </nav>
        <div class="container-fluid" style="padding-top:60px;">
            <div class="row">
                <div class="col">
                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
                </div>
            </div>
        </div>
        <nav class="navbar fixed-bottom navbar-light bg-light">
            <a class="navbar-brand" href="#">Fixed bottom</a>
            <form class="form-inline">
                <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
                <button class="btn btn-outline-secondary my-2 my-sm-0" type="submit">Search</button>
            </form>
        </nav>
        <script type="text/javascript" src="vendor/jquery-3.4.1.min.js"></script>
        <script type="text/javascript" src="vendor/bootstrap.bundle.min.js"></script>
    </body>
</html>
git add .
git commit -m "Add bootstrap and jquery"

Go back to project root (...\myCordovaProject)

cd ../..
zip cordovaExample.zip -r cordovaExample -x cordovaExample/node_modules/\*

Upload
https://build.phonegap.com/

Build

Deploy

Etc.

Run and test in browser...

cordova run browser

http://localhost:8000/index.html

...or on your phone with Phonegap Desktop App and PhoneGap Developer

https://phonegap.com/getstarted/ https://play.google.com/store/apps/details?id=com.adobe.phonegap.app

Links

https://cordova.apache.org/docs/en/latest/guide/cli/index.html https://cordova.apache.org/#getstarted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment