- Start the app:
yarn android:{env}
oryarn ios:{env}
(envs:dev
,staging
, andprod
) - Start metro bundler:
yarn start
- Lint the app:
yarn lint
- Test the app:
yarn test
- Install dependencies:
yarn
- Create a
.env
file in the root directory of the project, based on the.env.defaults
sample file and the extra constants that you may need. This will be your development env.
You can also create .env.prod
and .env.staging
to define environment variables for production and staging.
- Rename your new project using react-native-rename
- Start on android or ios:
yarn android:{env}
oryarn ios:{env}
(envs:dev
,staging
, andprod
)
If you don't want to make use of the Android Flavors and iOS Build Targets then you can run these commands instead:
For develop
react-native run-android
react-native run-ios
For other envs
ENVFILE=.env.{env} react-native run-ios
- Run the following command inside the
android/app
directory
keytool -genkey -v -keystore debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000
- Run the following command inside the
ios
directory
pod install
- After adding the project to CC, go to
Repo Settings
- On the
Test Coverage
tab, copy theTest Reporter ID
- Replace the current value of
CC_TEST_REPORTER_ID
on theconfig.yml file (.circleci/config.yml)
with the one you copied from CC
- Ask a developer for the release key and place it in
/android/app
- Add the following variables in
.env.prod
:
RELEASE_STORE_FILE
RELEASE_STORE_PASSWORD
RELEASE_KEY_ALIAS
RELEASE_KEY_PASSWORD
- Run
yarn android:release:{env}
- The generated APK can be found under
android/app/build/outputs/apk/{env}/app-release.apk
- Select on Xcode the scheme of the build target you want to create the release for.
- For the device select generic iOS device.
- Then go to Product -> Archive.
- After it is done processing and the archive succeeds the organizer will open. Here is where you can see all the previously generated archives.
The base is already equipped with three main environments: dev
, staging
, production
. All the env files you need to provide are as follows: .env
, .env.staging
, and .env.prod
.
If you want to add a new env here are the steps to follow:
- Create a new env file with the format
.env.{name}
.
- go to
android/app/build.gradle
and add the env file association toproject.ext.envConfigFiles
following the existing ones as example. - Scroll down to the
flavors
section and add a new flavor with the following format:
{name} {
applicationIdSuffix '.{name}'
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
}
- Inside
android/app/src
copy one of the existing env folders likestaging
and rename it with the name of your new flavor. - In that new folder you will see a folder called
values
and inside a file calledstrings.xml
there you can set the app name that is going to appear for this flavor. You can also set special app icons for each flavor insideres
folder. - (optional) go ahead and add new scripts in the
package.json
file for this new env. As you can see, the other envs already have scripts to run, build and build release, this will make your development workflow a lot easier. - you might need to open the android folder in Android Studio and do File -> Sync project with grade files
If you are looking for something quick and easy in the short term, there is one more way you can run the app with a custom env file, just run:
ENVFILE=.env.{env} react-native run-android
You can use build targets to configure different app-icons, splash, bundle-ids, etc.
Build targets are a great way to manage multiple envs in TestFlight. When you have staging and production builds that need testing by the client in TestFlight and you are not using build target this can become a bit of an issue.
Fortunately the base already comes with the build targets you will probably need to get to production: ReactNativeBase-Develop
, ReactNativeBase-Staging
and ReactNativeBase
which is for production use.
Each build target has its respective scheme already set up, they all have the same name as the build target except for the production one, that one is called ReactNativeBase-Prod
. This leaves ReactNativeBase
scheme free of an env setup just in case you don't want to use build targets.
To add a new build target do as follows:
- Open XCode and go to the project settings, there you should see a list of the already created targets.
- Right click in the
ReactNativeBase
build target (or your app's name if you have already renamed it) and select duplicate. - Select duplicate only.
- Rename the new build target appropriately.
- At the root of the
ios
folder a new copy of the info.plist file will be created. You also need to rename that file appropriately. - Since you have renamed the new build target's info.plist file, you need to go to the Build Settings of the new build target and in Packaging rewire the info.plist File attribute with the file's new name.
- A new scheme will also be created, rename it appropriately.
- Go to edit the scheme and in the left side bar select Build -> Pre-actions. Select the plus button and New run script action. In the code section of the action put as follows:
echo ".env.{name}" > /tmp/envfile
where name is the name of the env you created. - Add the new build target to your pod file:
target '{TargetName}' do
base_pods
use_native_modules!
end
- (optional) If you are using Fastlane, copy Fastlane's config from one of the other build targets and rename in the appropriate places, the files you need to look into are
ios/Fastfile
andios/Appfile
.
-
Staging
andDevelop
targets search for.env.staging
and.env
automatically (if the file it's not present, it will raise a build error). -
npm run ios:staging
andnpm run ios:develop
are available if you want to run the targets from the CLI.
If you don't want to use Build Targets, you have the option to just create new schemes for the base build target.
Create a new scheme and follow the step number 9 and 11 of Using different build targets.
If you are looking for something quick and easy in the short term, there is one more way you can run the app with a custom env file, just run:
ENVFILE=.env.{env} react-native run-ios
rootstrap/react-native-base#40
- React-Navigation
- PropTypes
- React-Native-Config
- ReactNativeLocalization
- Redux
- Redux-Thunk
- Redux-Persist
- Reselect
- humps
- validate.js
- immer
- lodash
- Jest
- Enzyme
The current configuration for redux-persist is on store/configureStore.js
.
The default configuration is the following:
- There's a defined
whitelist
where all reducers that want to be persisted must be declared. - The
storage
engine isAsyncStorage
but you can change it if needed, for example: https://github.com/CodingZeal/redux-persist-sensitive-storage if you need keychan storage on iOS. - If you ever need to set up migrations to keep your reducers up to date, please check this link.