A starter kit for React Native written in Typescript with ❤️. A production-ready app with below functions:
- Authentication: Firebase Auth
- Android: Facebook, Google, Email, Phone No.
- iOS: Facebook, Google, Email, Phone No, Apple.
- Navigation: React Navigation
- Internationalization: react-i18next
- Support dark/light theme, multiple primary colors.
- Main UI libraries: react-native-paper
- OTA update: codepush
- Error tracking: Sentry
- Analytics: Firebase Analytics
- Forms: Formik
- Persist data: async-storage
- Deep linking: React Navigation
- Local Notification: react-native-notifications
Another repo fastlane-credentials is used to store all credentials so the credentials are not shared to everyone. The structure of that repo:
- android (shared among multiple products/apps)
- app
- mobile.keystore (the keystore file of Android app)
- fastlane
- googlePlaySecretKey.json (the credential Fastlane use to publish to Playstore)
- keystore.properties (the credential to unlock the keystore file)
- certs (the folder Fastlane match uses to store iOS certificates - shared among multiple products/apps)
- ios (shared among multiple products/apps)
- .env.default (the credential Fastlane uses to build and publish app to Testflight)
- profiles (the folder Fastlane match uses to store iOS profiles - shared among multiple products/apps)
- tqt-mobile-starter-kit (the current app configuration)
- production (the production environment configuration)
- android
- app
- google-services.json (the credential Firebase uses)
- ios
- GoogleService-Info.plist (the credential Firebase uses)
- .env (the environment credentials mostly used by codepush)
- sentry.properties (the credentials sentry uses)
- staging (the production environment configuration, same structure as production)
...
We have 2 environments: production & staging. In each environment, we need to setup below apps:
- 1 Android app
- 1 iOS app
- 1 Firebase app
- 1 Facebook app
- 1 Sentry app
- 2 Appcenter (used for codepush) apps (see more)
- Development code stays at the develop branch
- Production code stays at the master branch
- To publish apps to the Playstore Alpha channel & Appstore Testflight, commit the code into the fastlane branch (use the fastlane-staging branch for the staging app)
- To publish apps to the Playstore Release channel, you should go to https://play.google.com/apps/publish and manually promote the app from the Playstore Alpha channel & update release notes (although Fastlane can automate it)
- To publish apps to the Playstore Release channel, you should go to https://appstoreconnect.apple.com and manually select the latest build & update release notes (although Fastlane can automate it)
- In case you want to update apps without publishing to store (only update javascript/typescript code), commit the code into the codepush branch (use the codepush-staging branch for the staging app) to publish it into the codepush Staging environment first. After testing is done, promote it to Production environment by committing code into the codepush-promote branch (use the codepush-promote-staging branch for the staging app)
- run Android:
yarn android
- run iOS:
yarn ios
- set environments (production/staging/etc), change related configurations (default is production):
yarn env production
yarn env staging
- update app version, for example 1.4:
yarn update-ver <latest-version>
- update app build number, for example 5 (should be ran by Github Actions):
yarn update-build <latest-build-number>
- validate source code
yarn validate
- get SHA1 of keystores
yarn android-signing
- install ImageMagick
brew install imagemagick
-
update
src/assets/images/app-icon-1024.png
-
run
yarn update-icons
- for splash screen, follow react-native-bootsplash
Follow rnfirebase
- prepare credentials in the exact locations below:
android
app
mobile.keystore
fastlane
googlePlaySecretKey.json
keystore.properties
mobile.keystore: Learn how to generate keystore here
keystore.properties: store credentials to unlock mobile.keystore
googlePlaySecretKey.json: credentials used by Fastlane to publish app to store. Learn how to generate it here
- build app (optional)
yarn android-build
- build app to apk (optional)
yarn android-build-apk
- build app & publish to Alpha channel
yarn android-alpha
- prepare credentials in the exact locations below:
ios
.env.default
.env.default: fastlane environment variables stored here
MATCH_APP_IDENTIFIER= // all app ids
MATCH_GIT_URL= // match git url
MATCH_PASSWORD= // match password
APPLE_USERNAME= // apple username
APPLE_ITC_TEAM_ID= // apple itc team id
APPLE_TEAM_ID= // apple team id
FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD= // apple app password
FASTLANE_SESSION= // fastlane session
- run
cd ios && fastlane match
to initialize match & populate credentials to the git repo
- (update FASTLANE_SESSION)[https://docs.fastlane.tools/best-practices/continuous-integration/] by running
fastlane spaceauth -u [email protected]
- build app (optional)
yarn ios-build
- build app & publish to Testflight
yarn ios-testflight
- register a new account in https://appcenter.ms, create a new organization
- create 1 app for Android & 1 app for iOS using appcenter cli under the newly created organization
- run below commands to create Staging and Production deployments (read this guideline)
appcenter codepush deployment add Staging -a your-organization/your-app-android
appcenter codepush deployment add Production -a your-organization/your-app-android
appcenter codepush deployment add Staging -a your-organization/your-app-ios
appcenter codepush deployment add Production -a your-organization/your-app-ios
- run
appcenter codepush deployment list -a your-organization/your-app-android -k
to get deployments keys (same for ios app) - run below commands to release Staging version and promote it to Production:
appcenter codepush release-react -a your-organization/your-app-android --description "deployment message"
appcenter codepush release-react -a your-organization/your-app-ios --description "deployment message"
appcenter codepush promote -a your-organization/your-app-android -s Staging -d Production
appcenter codepush promote -a your-organization/your-app-ios -s Staging -d Production
- to get deployment history, run
appcenter codepush deployment history Staging -a your-organization/your-app-android
- make another environment for the staging app (if you have a separate one)
https://app-privacy-policy-generator.firebaseapp.com/
Create a (new project)[https://github.com/react-native-community/react-native-template-typescript]
npx react-native init mobile --template react-native-template-typescript