This is the main mobile application for Hoard. This is a React Native application that will be able to be deployed on both iOS and Android.
Running application for local development
- Ensure yarn is installed in your development environment
yarnto install dependencies
yarn startto start packaging server
yarn androidto install and the application on a simulator, for iOS and Android respectively
- Note: The process for running the android simulator is a bit more complicated than the ios side. Please see the "Building Project with Native Code" tab of the getting started React Native documentation
Installing on a device
See the following guides for generating a package for deployment
The generated .apk or .ipa can then be uploaded to Hoard's HockeyApp account for testing.
Table of Contents
- Available Scripts
- Writing and Running Tests
- Environment Variables
- Adding Flow
- Customizing App Display Name and Icon
If Yarn was installed when the project was initialized, then dependencies will have been installed via Yarn, and you should probably use it to run these commands as well. Unlike dependency installation, command running syntax is identical for Yarn and NPM at the time of this writing.
Runs your app in development mode.
Open it in the Expo app on your phone to view it. It will reload if you save edits to your files, and you will see build errors and logs in the terminal.
Sometimes you may need to reset or clear the React Native packager's cache. To do so, you can pass the
--reset-cache flag to the start script:
npm start -- --reset-cache # or yarn start -- --reset-cache
Runs the jest test runner on your tests.
npm run ios
npm start, but also attempts to open your app in the iOS Simulator if you're on a Mac and have it installed.
npm run android
npm start, but also attempts to open your app on a connected Android device or emulator. Requires an installation of Android build tools (see React Native docs for detailed setup). We also recommend installing Genymotion as your Android emulator. Once you've finished setting up the native build environment, there are two options for making the right copy of
adb available to Create React Native App:
Using Android Studio's
- Make sure that you can run adb from your terminal.
- Open Genymotion and navigate to
Settings -> ADB. Select “Use custom Android SDK tools” and update with your Android SDK directory.
- Find Genymotion’s copy of adb. On macOS for example, this is normally
- Add the Genymotion tools directory to your path (instructions for Mac, Linux, and Windows).
- Make sure that you can run adb from your terminal.
npm run eject
This will start the process of "ejecting" from Create React Native App's build scripts. You'll be asked a couple of questions about how you'd like to build your project.
Warning: Running eject is a permanent action (aside from whatever version control system you use). An ejected app will require you to have an Xcode and/or Android Studio environment set up.
Customizing App Display Name and Icon
You can edit
app.json to include configuration keys under the
To change your app's display name, set the
expo.name key in
app.json to an appropriate string.
To set an app icon, set the
expo.icon key in
app.json to be either a local path or a URL. It's recommended that you use a 512x512 png file with transparency.
Writing and Running Tests
This project is set up to use jest for tests. You can configure whatever testing strategy you like, but jest works out of the box. Create test files in directories called
__tests__ or with the
.test extension to have the files loaded by jest. See the the template project for an example test. The jest documentation is also a wonderful resource, as is the React Native testing tutorial.
You can configure some of Create React Native App's behavior using environment variables.
Configuring Packager IP Address
When starting your project, you'll see something like this for your project URL:
exp://localhost:19000, the Expo client app will still try to retrieve your app at the IP address that the start script provides.
In some cases, this is less than ideal. This might be the case if you need to run your project inside of a virtual machine and you have to access the packager via a different IP address than the one which prints by default. In order to override the IP address or hostname that is detected by Create React Native App, you can specify your own hostname via the
REACT_NATIVE_PACKAGER_HOSTNAME environment variable:
Mac and Linux:
REACT_NATIVE_PACKAGER_HOSTNAME='my-custom-ip-address-or-hostname' npm start
set REACT_NATIVE_PACKAGER_HOSTNAME='my-custom-ip-address-or-hostname' npm start
The above example would cause the development server to listen on
React Native works with Flow out of the box, as long as your Flow version matches the one used in the version of React Native.
To add a local dependency to the correct Flow version to a Create React Native App project, follow these steps:
- Find the Flow
[version]at the bottom of the included .flowconfig
npm install --save-dev firstname.lastname@example.org(or
yarn add --dev email@example.com), where
x.y.zis the .flowconfig version number.
"flow": "flow"to the
scriptssection of your
// @flowto any files you want to type check (for example, to
Now you can run
npm run flow (or
yarn flow) to check the files for type errors.
You can optionally use a plugin for your IDE or editor for a better integrated experience.
To learn more about Flow, check out its documentation.
If you're unable to load your app on your phone due to a network timeout or a refused connection, a good first step is to verify that your phone and computer are on the same network and that they can reach each other. Create React Native App needs access to ports 19000 and 19001 so ensure that your network and firewall settings allow access from your device to your computer on both of these ports.
Try opening a web browser on your phone and opening the URL that the packager script prints, replacing
http://. So, for example, if underneath the QR code in your terminal you see:
Try opening Safari or Chrome on your phone and loading
If this works, but you're still unable to load your app by scanning the QR code, please open an issue on the Create React Native App repository with details about these steps and any other error messages you may have received.
If you're not able to load the
http URL in your phone's web browser, try using the tethering/mobile hotspot feature on your phone (beware of data usage, though), connecting your computer to that WiFi network, and restarting the packager.
iOS Simulator won't open
If you're on a Mac, there are a few errors that users sometimes see when attempting to
npm run ios:
- "non-zero exit code: 107"
- "You may need to install Xcode" but it is already installed
- and others
There are a few steps you may want to take to troubleshoot these kinds of errors:
- Make sure Xcode is installed and open it to accept the license agreement if it prompts you. You can install it from the Mac App Store.
- Open Xcode's Preferences, the Locations tab, and make sure that the
Command Line Toolsmenu option is set to something. Sometimes when the CLI tools are first installed by Homebrew this option is left blank, which can prevent Apple utilities from finding the simulator. Make sure to re-run
npm/yarn run iosafter doing so.
- If that doesn't work, open the Simulator, and under the app menu select
Reset Contents and Settings.... After that has finished, quit the Simulator, and re-run
npm/yarn run ios.