Differences
This shows you the differences between two versions of the page.
— | devwiki:cordova [2021/08/28 07:42] (current) – created ying | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Cordova for cross-platform web app ====== | ||
+ | |||
+ | * pre-install | ||
+ | * android studio (https:// | ||
+ | * jdk 8, as jdk10 not working with Cordova for some reason, cause " | ||
+ | * (Java SE 8u https:// | ||
+ | * set env variable: JAVA_HOME: / | ||
+ | |||
+ | * install | ||
+ | - install node.js v8 LTS: https:// | ||
+ | - install cordova < | ||
+ | |||
+ | ====== Build App for Web and Android ====== | ||
+ | |||
+ | * ref: | ||
+ | * https:// | ||
+ | |||
+ | * creation step | ||
+ | - under your dev projects folder, create app folder by < | ||
+ | - the whole web content is under ./www/ folder | ||
+ | - add target platform < | ||
+ | cordova platform add android | ||
+ | // web | ||
+ | cordova platform add browser@5.0.1 | ||
+ | // check platform by | ||
+ | cordova platform ls | ||
+ | // check requirement by | ||
+ | cordova requirements | ||
+ | // test run on browser | ||
+ | cordova run browser | ||
+ | </ | ||
+ | - build < | ||
+ | cordova build | ||
+ | // build android | ||
+ | cordova build android | ||
+ | // build android release insteal debug apk | ||
+ | cordova build android --release | ||
+ | </ | ||
+ | - run < | ||
+ | - just usb to put the apk on your android device, use file manager to open the apk and install, So Simple | ||
+ | ====== Build App for iOS ====== | ||
+ | |||
+ | * you need: | ||
+ | * Mac OS X w admin login | ||
+ | * Xcode | ||
+ | * step to get demo run: | ||
+ | - install node.js for mac (for mac, recommend get everything as latest, that is how Apple does), then < | ||
+ | - install related addition tool < | ||
+ | sudo npm install -g ios-deploy | ||
+ | // note, if you fail above, you may need type based on error msg: sudo npm install -g ios-deploy --unsafe-perm=true | ||
+ | </ | ||
+ | - to make sure you got all you need < | ||
+ | cordova requirements | ||
+ | // most likely it will ask you to install pod, here is command, and it take a while | ||
+ | sudo gem install cocoapods | ||
+ | pod setup | ||
+ | </ | ||
+ | - create project in home directory, since Mac secure / root directory < | ||
+ | mkdir nodeProj;cd nodeProj | ||
+ | cordova create HelloApp com.HelloCom.HelloApp HelloApp | ||
+ | cd HelloApp | ||
+ | cordova platform add ios | ||
+ | cordova build ios | ||
+ | </ | ||
+ | - if you want to run or compile for ipa < | ||
+ | // run in emulator | ||
+ | cordova emulate ios | ||
+ | // compile for device will error signing required, you may need addition workaround if you dont have paid developer account from apple | ||
+ | cordova build ios --device | ||
+ | |||
+ | // if you want to do simply, open the project with Xcode, the top left UI take you choice on deploy device drop list and real device list, | ||
+ | // of course, if you have Apple ID (not necessarily paid program account), if you select top App name in left hierarchy view panel, you can use personal account (Team as Personal Team) to create a free-6-day deloy cert in code signing section | ||
+ | open ./ | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | **Note** | ||
+ | * in the build folder, you may find the result app is a .app file, not a ipa (which is actually a zip of .app) | ||
+ | * you need to hack a way to convert if without paid developer account, ref: | ||
+ | * https:// | ||
+ | * https:// | ||
+ | * https:// | ||
+ | * https:// | ||
+ | * if you want to put ipa into your ipad without paid developer account, you can but only last for 7 days, refer to: | ||
+ | * https:// | ||
+ | * iOS signing: http:// | ||
+ | |||
+ | |||
+ | **Update iOS from main cordova project** | ||
+ | * code < | ||
+ | cordova platform add ios | ||
+ | </ | ||
+ | ====== Put ipa on iOS Device ====== | ||
+ | |||
+ | * The most painful part of all development process, you better pay the 99USD apple program to save as much trouble as possible, since so many certificates and sign work required. If you seriously want to do iOS app, pay first to save the time. | ||
+ | |||
+ | * when you need to put ipa into other people' | ||
+ | * https:// | ||
+ | |||
+ | ====== Function and Features ====== | ||
+ | |||
+ | * in app browser function < | ||
+ | * to make it work, it need to | ||
+ | * add white list plugin: https:// | ||
+ | * then, add your site link to allow inside platform name=" | ||
+ | * add allow unsafe connection like this "' | ||
+ | <meta http-equiv=" | ||
+ | make it something like this | ||
+ | https:// | ||
+ | * also make your link in html like this < | ||
+ | * more option refer to inappbrowser plugin page: https:// | ||
+ | ====== Addition Resource ====== | ||
+ | |||
+ | **Generate Icons and Screen for platforms** | ||
+ | * online tool: https:// | ||
+ | - use it to generate icons, and put them into ./res folder, also update the config.xml file in the description provided in the page. | ||
+ | * another npm tool use imagemagick: | ||