Note: this file is over 50 lines long because it contains a lot of relevant information in one place.
- all code is in TypeScript, using
.tsx
for files containing jsx, or.ts
for those without - no semicolons
- 2 spaces
- newline at end of file (check your editor settings)
- trim whitespace on save (check your editor settings)
- keep code in appropriate packages under
packages/<package>
- discuss with team before adding a new package
- only use third-party libraries when absolutely required
- no hardcoded text in the app, belongs in
packages/language/<language>
- no style outside of
packages/theme/default
(we may add themes later) - for the most part, files should be called
index.ts
with any dependencies in./lib/<function-name>.ts
- all snake-case directory names and file names, leads to less issues
- code under ui should generally begin with
import React, { Component } from 'react'
to avoid linter errors forReact
- ui components generally look like
export default class ComponentName extends Component<Props, State>
Note: to import from a package see .babelrc
and tsconfig.json
for package name rewrites. Important: no relative imports starting with ../
- in other words never assume what's above you in the file tree - you must be able to move folders around without consequence.
Note: TypeScript code is compiled into lib
top level directory.
-
credit-protocol
contains the client library to connect to BlockMason's credit-protocol server.- i.e.
import { CreditProtocolClient } from 'credit-protocol'
- i.e.
-
language
contains all text strings and functions used to generate text.- i.e.
import language from 'language'; const { privacyPolicy, pendingTransactionsLanguage } = language
- i.e.
-
lndr/*
is the core application logic and should have zero references toreact
or any other ui.- i.e.
import LNDR from 'lndr'
- i.e.
-
theme/*
contains all stylesheets.- i.e.
import style from 'theme/button'
- i.e.
-
ui/*
is thereact-native
user interface.- i.e.
import App from 'ui/app'
- i.e.
Copy, rename, and update the files android/app/src/main/assets/airshipconfig.properties.example
and ios/AirshipConfig.plist.example
with the proper UrbanAirship API key and secret from the Blockmason account on urbanairship.com
Log in to Firebase (https://console.firebase.google.com/u/0/project/lndr-english/settings/general/android:com.lndr) and download the google-services.json and GoogleService-Info.plist files and add them to the android and ios folders.
- Ensure that CocoaPods and Yarn are both installed (
sudo gem install cocoapods
andbrew install yarn
) yarn
(this installs the packages)- Fill in the
.env.example
with the proper information and save as.env
. (info is in airshipconfig.properties or AirshipConfig.plist) yarn run setup:env
- (in new terminal)
yarn run typescript
- (in new terminal)
yarn start
-
Put
GoogleService-Info.plist
inios/
-
Put
AirshipConfig.plist
inios/
-
Put
PayPalConfig.plist
inios/
-
Run
cd ios && pod install && cd ..
-
react-native run-ios
Setting up ANDROID_HOME env variable
export ANDROID_HOME=/<SDK installation location>
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
source ~/.bash_profile
will be found in android studio (if installed) in Preferences -> Appearance & Behaviour -> System Settings -> Android SDK
Config files
- Put
google-services.json
inandroid/app/
- Put
gradle.properties
inandroid/
- Put
airshipconfig.properties
inandroid/app/src/main/assets/
- Put
paypalconfig.properties
inandroid/app/src/main/assets/
Running Android
- Run
react-native run-android
In new tabs
react-native log-ios
react-native log-android
- Download and start React Native Debugger, then select 'Debug Remotely' from the simulator/emulator
- in separate terminal sessions, run
yarn start
andyarn run typescript
react-native run-android
react-native bundle --dev false --platform android --entry-file index.android.js --bundle-output ./android/app/build/intermediates/assets/debug/index.android.bundle --assets-dest ./android/app/build/intermediates/res/merged/debug
cd android
./gradlew assembleDebug
This project uses (Jest)[http://jestjs.io/docs/en/tutorial-react-native.html], which is the preferred testing framework for React Native.
Tests are stored in the top-level "tests" folder which mimics the structure of the "packages" folder.
To run tests type yarn test
To create a new snapshot after changing a .tsx
file, run jest -u
XCode 10.0 or higher is required, which in turn requires macOS Sierra (10.12) or higher.
Private keys to sign the build: ios_dist_bm.p12 for iOS and blockmason-lndr-android.keystore for Android
-
Get the gradle.properties file with the keystore passwords and put it in the 'android' directory.
-
Get the blockmason-lndr-android.keystore file and put it in the 'android/app' directory.
-
Run 'cd android && ./gradlew assembleRelease' from the top-level directory.
-
The signed APK will be at 'android/app/build/outputs/apk/app-release.apk'
-
Upload the APK to the Play Store
-
Navigate to directory ios/
-
Run
sudo gem install cocoapods
-
Run
pod install
-
Open XCode, click
Open another project...
at bottom right, go to the directory ios/ , selectLNDR.xcworkspace
-
Open the directory structure in the left side menu, go into
LNDR
, openInfo.plist
, clickApp Transport Security Settings
, thenException Domains
, and deletelocalhost
entry -
In top menu go to Product > Scheme > Edit Scheme (
LNDR
scheme should be selected), in Run > Info change the Build Configuration to 'Release' -
Run the command Product > Clean (command + shift + K), then Product > Build (command + B)
-
Once the build finishes, run Product > Archive
-
Click 'Upload to App Store' on the right side, and follow steps to upload.
- in separate terminal sessions, run
yarn start
andyarn run typescript
./build-android.sh