All Projects → johnkmzhou → Cordova Create React App

johnkmzhou / Cordova Create React App

A tutorial on how to set up a Cordova project using Create React App.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Cordova Create React App

Create Lit App
Create LitHTML apps with no build configuration. (LitHTML/Redux/Webpack/Express)
Stars: ✭ 108 (-35.33%)
Mutual labels:  webpack, starter
React Redux Starter
A basic template that consists of the essential elements that are required to start building a Single Page Application using React, React Router, Redux, Bootstrap 4, Sass, and Webpack
Stars: ✭ 116 (-30.54%)
Mutual labels:  webpack, starter
Cra Build Watch
A script for create-react-app that writes development builds to the disk
Stars: ✭ 110 (-34.13%)
Mutual labels:  webpack, create-react-app
Webpack Format Messages
Beautiful formatting for Webpack messages; ported from Create React App!
Stars: ✭ 103 (-38.32%)
Mutual labels:  webpack, create-react-app
Generator Create Redux App
Add redux, emotion-js and other useful libraries like react-router in top of create-react-app
Stars: ✭ 137 (-17.96%)
Mutual labels:  create-react-app, starter
Conf
Landing page for event React Conf Brazil
Stars: ✭ 104 (-37.72%)
Mutual labels:  webpack, create-react-app
React Redux Auth0 Kit
Minimal starter boilerplate project with CRA, React, Redux, React Router and Auth0 authentication
Stars: ✭ 115 (-31.14%)
Mutual labels:  webpack, create-react-app
React Webpack Babel
Simple React Webpack Babel Starter Kit
Stars: ✭ 1,241 (+643.11%)
Mutual labels:  webpack, starter
Webpack Demo
webpack 4 config. demo ⚙️
Stars: ✭ 131 (-21.56%)
Mutual labels:  webpack, tutorial
Ionic2 Reddit Reader
Ionic 2 Sample App
Stars: ✭ 128 (-23.35%)
Mutual labels:  webpack, cordova
Sambell
wake me when it's quitting time
Stars: ✭ 101 (-39.52%)
Mutual labels:  webpack, create-react-app
Micro Starter
[Deprecated] 🔷 Basic (opinionated) starter kit for a micro app with webpack build
Stars: ✭ 144 (-13.77%)
Mutual labels:  webpack, starter
Angular Webpack Starter
🌟 Angular Webpack Starter with AoT compilation, Lazy-loading, Tree-shaking, and Hot Module Reload (Updated to 4.1.0!)
Stars: ✭ 91 (-45.51%)
Mutual labels:  webpack, starter
Es6 Webpack2 Starter
🚀 A template project for es6/7, webpack2/3, sass and postcss
Stars: ✭ 106 (-36.53%)
Mutual labels:  webpack, starter
Phaser Es6 Webpack
A bootstrap project for create games with Phaser + ES6 + Webpack.
Stars: ✭ 1,266 (+658.08%)
Mutual labels:  webpack, cordova
Web Extension Starter
Typescript, React, Redux, Styled-Component and Webpack based sample extension boilerplate. Runs on Chrome and Firefox. Sample chrome extension.
Stars: ✭ 115 (-31.14%)
Mutual labels:  webpack, starter
Cordovue
A sample Apache Cordova application using VueJS.
Stars: ✭ 66 (-60.48%)
Mutual labels:  webpack, cordova
Ionic Typescript Mdha Starter
📱 This is an boilerplate starter project I use to bootstrap mobile applications. It is built with Ionic, AngularJS, TypeScript, and runs in Cordova. It is built upon the Visual Studio Tools for Apache Cordova project provided in Visual Studio 2015.
Stars: ✭ 70 (-58.08%)
Mutual labels:  starter, cordova
Ionic Typescript Starter
📱 Platform and IDE agnostic starter project for building mobile apps with Ionic and TypeScript.
Stars: ✭ 124 (-25.75%)
Mutual labels:  starter, cordova
Modern Wasm Starter
🛸 Run C++ code on web and create blazingly fast websites! A starter template to easily create WebAssembly packages using type-safe C++ bindings with automatic TypeScript declarations.
Stars: ✭ 140 (-16.17%)
Mutual labels:  webpack, starter

Cordova Create React App Tutorial

I was dissatisfied with tutorials that didn't meet my needs, boilerplate projects with incompatible dependencies, and yeoman generators with errors so I decided to make a tutorial to help others set up their initial project. Also if you're migrating an existing web app to Cordova, this will provide insight into what you need to get that to work.

Note that I'm running this tutorial with Cordova 8 but it should work with other versions.

Installation

Install the Create React App CLI.

npm install -g create-react-app

Install the Cordova CLI.

npm install -g cordova

Create the project.

create-react-app tutorial

Because we will be editing the Webpack configuration, go to your Create React App project directory and run:

yarn run eject

Go to your config/paths.js file and change

appBuild: resolveApp('build') to appBuild: resolveApp('www')

Because your files will be served from file:// add this line to your package.json (https://github.com/facebookincubator/create-react-app/issues/1094):

"homepage": "./"

This is specific to create-react-app. In other projects you would need to ensure your paths are not prepended with a /.

Now we will need some files from a Cordova project.

cordova create tutorial com.example.tutorial Tutorial

Next copy the config.xml from your Cordova project to your Create React App project. The other files and directories in the Cordova project are not currently used in this tutorial but take note of them because you may make use of them as your project develops. For example, the res directory would be where you would place icons and splash screens.

Next modify your index.js so it looks like:

const startApp = () => {
  ReactDOM.render(<App />, document.getElementById('root'));
  registerServiceWorker();
};

if(window.cordova) {
  document.addEventListener('deviceready', startApp, false);
} else {
  startApp();
}

And add <script type="text/javascript" src="cordova.js"></script> to index.html. You may also want to add

<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *; img-src 'self' data: content:;">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">

Now we can build our output to the www directory.

yarn run build

The rest of these instructions have files and changes that are not in the current repository due to the nature of the dependencies that have to be brought down. Also I didn't want to tie the tutorial down with specific versions of Android and iOS.

To target platforms:

cordova platform add ios

cordova platform add android

You need to install SDKs for each platform that you wish to target. Read this to check what requirements need to be satisfied: https://cordova.apache.org/docs/en/latest/guide/cli/index.html#install-pre-requisites-for-building Generally you will probably have to install Android Studio, XCode, SDKs, emulators, build systems, etc.

To test the app run:

cordova emulate android

cordova emulate ios

To test on a connected devie run:

cordova run android

cordova run ios

Recommended Plugins

Often what you will find is that a plugin is no longer being maintained. In that scenario your options are either to find a fork that resolves the issues you are encountering or, as a last ditch effort, attempt to fix it yourself.

Firebase OAuth Authentication

To authenticate using OAuth Providers follow these instructions: https://firebase.google.com/docs/auth/web/cordova

Because the cordova-universal-links-plugin is outdated you should instead install this fork:

cordova plugin add https://github.com/walteram/cordova-universal-links-plugin.git --save

Firebase Analytics and Push Notifications

Due to various issues that haven't beeen resolved in the latest npm package of cordova-plugin-firebase I recommend getting the version of the plugin directly from git

cordova plugin add https://github.com/arnesson/cordova-plugin-firebase.git --save

iOS Deployment

First, sign up for a paid Apple Developer Account. In Xcode, open your project from /platforms/ios and go to your Preferences > Accounts. Add the Apple ID that was used for the developer account. Select your Agent Role and click on Manage Certificates.. and click on the + icon to generate a signing certificate.

Next, go to https://developer.apple.com/account/ios/profile and add a new provisioning profile. Select your development or distribution option and on the next page fill your App ID Description (for example, My Cordova App) and your bundle ID that can be found in config.xml.

Next, in Xcode go to your project navigator and select your project. In a drop down list make sure your project is selected as a target. Then, under Signing, select your Team and generate your signing certificate.

To prepare for distribution on the Apple App Store, you need to create an archive. In Xcode make sure the app is properly provisioned and signed for distribution. Next run yarn build followed by cordova prepare to copy any assets and plugins. Then in Xcode, ensure the version and build numbers are properly set and choose a generic device target from the Scheme toolbar menu. Then choose Product > Archive. There is an issue uploading to the App Store from the Archives window. Instead export the archive and upload it via Application Loader. After uploading the build to iTunes Connect, if the build is still in the "Processing" phase after an hour, attempt to upload another build because more than likely there's probably an issue with Apple's servers.

Android Deployment

First, sign up for a Google Play Developer account. Next, run yarn build followed by cordova build android --release which will result in an apk that needs to be signed. Then run:

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore android.keystore app-release-unsigned.apk alias-name

where android.keystore is the location of the keystore and alias-name is the alias for your key. Make sure you have Android Studio installed because it will also come with the zipalign tool. For Mac OS you can find it in ~/Library/Android/sdk/build-tools/{version}/zipalign. Then run:

~/Library/Android/sdk/build-tools/{version}/zipalign -v 4 app-release-unsigned.apk release.apk

followed by uploading the build to the Google Play Console.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].