How to setup a Cordova app

Install Cordova

Note you must have node installed, otherwise run brew install node.

npm install -g cordova
cordova create hello com.example.hello HelloWorld
cordova platform add ios
cordova platform add android

Install Android studio

brew update && brew install gradle

Accept all andriod licenses

cd ~/Library/Android/sdk/tools/bin/
./sdkmanager --licenses

Install xcode from app store

brew install ios-deploy
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

Build Apps

cordova build

Point to Web App

To prevent app from opening browser, inside add

<allow-navigation href="*" />

Method 1

Edit config.xml

Replace

<content src="index.html" />

with

<content src="http://127.0.0.1:3000/" />

Method 2

Edit index.html

<html>
    <head>
        <script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
          <script type="text/javascript">
          function onBodyLoad()
          {
              document.addEventListener("deviceready", onDeviceReady, false);
              window.location.href = "http://localhost:3000/";
          }
          function onDeviceReady()
          {
              // do your thing!
          }
          </script>
          <script type="text/javascript" charset="utf-8" src="phonegap-1.3.0.js"></script>
    </head>
    <body onload="onBodyLoad()">
    </body>
</html>

Connect iOS device

  1. Connect phone
  2. Open xcode and select device: https://www.twilio.com/blog/2018/07/how-to-test-your-ios-application-on-a-real-device.html
  3. Enable signing: https://stackoverflow.com/questions/39524148/xcode-error-code-signing-is-required-for-product-type-application-in-sdk-ios
  4. You should now see the app located on your home screen. If you open it and receive and untrusted iOS prompt. Go to Settings > General > Device Management > Trust device. https://support.apple.com/en-ca/HT204460

Resources Used