Follow this guide for setting up React Native development environment.
git clone https://github.com/fmidev/weather-app.git
cd weather-app
yarn install
Obtain Google Maps API key and place it in .env
as depicted in .env.default
. Guides and troubleshooting from react-native-maps documentation
Create a keystore.properties
file in android/
folder:
cd android && touch keystore.properties
and add placeholder content:
storePassword=YOUR_STORE_PASSWORD
keyPassword=YOUR_KEY_PASSWORD
keyAlias=YOUR_KEY_ALIAS
storeFile=YOUR_KEYSTORE_FILE
Alternatively these can be provided as environment variables (e.g. in CI/CD pipeline):
WEATHER_APP_RELEASE_STORE_PASSWORD=YOUR_STORE_PASSWORD
WEATHER_APP_RELEASE_KEY_PASSWORD=YOUR_KEY_PASSWORD
WEATHER_APP_RELEASE_KEY_ALIAS=YOUR_KEY_ALIAS
WEATHER_APP_RELEASE_STORE_FILE=YOUR_KEYSTORE_FILE
Gradle will throw an error if one of the above is missing on yarn android
.
To sign the app on release builds you must create a keystore file, see android documentation and change the contents of keystore.properties
or environment variables accordingly.
Before running iOS or Android start metro: yarn start
. Also make sure you have a valid DefaultConfig.ts.
Open {PROJECT_DIR}/android in Android Studio and wait build to be completed
Create / open Android virtual device (tested with: Pixel 2, API Level 29, Android 10.0)
yarn android
/Users/oksman/Library/Android/sdk
adb
's list of devices, for example:➜ sdk ./platform-tools/adb devices
List of devices attached
R5CR207HAFP device
➜ sdk ./platform-tools/adb reverse tcp:8081 tcp:8081
8081
If you have arm-based mac, do these before running:
post_install do |installer| installer.pods_project.build_configurations.each do |config| config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64" end end
If you have problems you might need to do these as well:
rm -rf ~/Library/Developer/Xcode/DerivedData/ && pod deintegrate && pod update
You might need to install ios-deploy to be able to run from command line
npm install -g ios-deploy
If installing Node with nvm and try to start app from Xcode you might need to do this so Xcode finds Node.
ln -s $(which node) /usr/local/bin/node
Run project:
cd ios && pod install && cd ..
npx react-native run-ios
By default, the Metro server and the application use port 8081 to communicate with each other. In some environments, the port can be reserved, which causes the application to fail with the following error message:
"Unable to load script. Make sure you're either running Metro (run 'npx react-native start') or that your bundle 'index.android.bundle' is packaged correctly for release."
This behaviour can be fixed by changing the port to e.g. 8080. To change the port, the following commands must be run:
yarn start --port 8080
yarn android --port 8080
(or npx react-native run-android --port 8080
)cp defaultConfig.ts.example defaultConfig.ts
edit defaultConfig.ts
The units supported by the application are described on the table below. Note that you can only use the depicted unit abbreviations.
Parameter | Units |
---|---|
temperature | 'C', 'F' |
precipitation | 'mm', 'in' |
wind | 'm/s', 'km/h', 'mph', 'bft', 'kn' |
pressure | 'hPa', 'inHg', 'mmHg', 'mbar' |
Table of abbreviations and their corresponding units.
Abbreviation | Unit |
---|---|
'C' | celsius |
'F' | fahrenheit |
'mm' | millimeter |
'in' | inch |
'm/s' | meters per second |
'km/h' | kilometers per hour |
'mph' | miles per hour |
'bft' | beaufort |
'kn' | knot |
'hPa' | hehtopascal |
'inHg' | inch of mercury |
'mmHg' | millimeter of mercury |
'mbar' | millibar |
Test are located in e2e-directory
. To run tests use commands
yarn e2e:build:ios
yarn e2e:test:ios
or
yarn e2e:build:android
yarn e2e:test:android
Most likely you have to change simulator names in .detoxrc.json
to match your environment. Android emulator is quite sluggish and it is faster and more reliable to run tests with iOS simulator.