Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: nixify react native setup #3108

Merged
merged 7 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .detoxrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = {
emulator: {
type: "android.emulator",
device: {
avdName: "Pixel_API_34_AOSP",
avdName: "Pixel_API_34",
},
},
},
Expand Down
10 changes: 7 additions & 3 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
if [ -f ".env.local" ]; then
dotenv .env.local
fi
dotenv .env.local
fi

use flake ./dev
use flake .

# One time installs
# xcodes install 15.2
# xcodes runtimes install "iOS 17.0"
4 changes: 2 additions & 2 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ jobs:
sdkmanager --install 'build-tools;34.0.0' platform-tools > /dev/null
sdkmanager --install emulator --channel=0 > /dev/null
sdkmanager --install 'system-images;android-34;google_apis_playstore;arm64-v8a' --channel=0 > /dev/null
echo no | avdmanager create avd --force -n Pixel_API_34_AOSP --abi 'google_apis_playstore/arm64-v8a' --package 'system-images;android-34;google_apis_playstore;arm64-v8a' --device 'pixel_6a'
emulator -avd Pixel_API_34_AOSP -gpu swiftshader_indirect -no-boot-anim &
echo no | avdmanager create avd --force -n Pixel_API_34 --abi 'google_apis_playstore/arm64-v8a' --package 'system-images;android-34;google_apis_playstore;arm64-v8a' --device 'pixel_6a'
emulator -avd Pixel_API_34 -gpu swiftshader_indirect -no-boot-anim &
adb wait-for-device

- name: Run Detox Tests on Android Emulator
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,5 @@ android/app/src/main/assets
*.tmp.ci
artifacts
.direnv

ios/.xcode.env.local
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ tilt-up:

tilt-down:
cd dev && tilt down

emulator:
emulator -avd Pixel_API_34 -gpu swiftshader
27 changes: 4 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,18 @@ This repository is the Blink mobile application. The goal is to make a mobile ap

<img src=".readme/screenshot-1.png" alt="Screenshot 1" width="150"> <img src=".readme/screenshot-2.png" alt="Screenshot 2" width="150"> <img src=".readme/screenshot-3.png" alt="Screenshot 3" width="150"> <img src=".readme/screenshot-4.png" alt="Screenshot 4" width="150">

## Contributing

If you wish to contribute see [CONTRIBUTING.MD](./CONTRIBUTING.MD)

## Start

Prerequisite -- [Set up React Native](https://reactnative.dev/docs/environment-setup) by following the instructions in the **React Native CLI Quickstart** tab

Clone into the project

cd into the directory
## Developing

type `yarn install`
The development docs are in [DEV.md](./docs/dev.md)

type `yarn start`

In another window
type `yarn ios` or `yarn android` to run locally.

The app is built and pushed to the App Store and Play Store on demand with CircleCI.

To run the app fully locally the backend must also be set up by following the instructions at https://github.com/GaloyMoney/galoy.
## Contributing

---
If you wish to contribute see [CONTRIBUTING.MD](./CONTRIBUTING.MD)

### _Notes for Running on M1 Mac:_

The app currently only builds for x86_64 simulators. Simulators prior to IOS 13.7 are x86_64 by default, however starting with 13.7 they become platform specific. In order to get an x86_64 simulator of a newer IOS version, one must set XCode to open in [emulation using Rosetta](https://www.macworld.com/article/338843/how-to-force-a-native-m1-mac-app-to-run-as-an-intel-app-instead.html). To run the project, open [GaloyApp.xcworkspace](./ios/GaloyApp.xcworkspace/) in XCode, choose an x86_64 simulator, and click the play button. This should start the Metro bundler in a new terminal as well as launch the simulator with the app.

---

## Running Storybook

From the command line in your generated app's root directory, enter `yarn storybook`
Expand Down
105 changes: 105 additions & 0 deletions docs/dev.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Development Environment
Developing the Blink Mobile app for the Galoy Backend can be done in a variety of ways but the officially supported method is via [Nix Flake](../flake.nix) at the root of the repository.

## Prerequisites

Before you start, ensure you have the following installed on your system:

- [Nix (set up with Flakes)](https://github.com/DeterminateSystems/nix-installer) - Make sure you have flake support turned on
- [Direnv](https://direnv.net) - Hooked up to your shell
- [Docker](https://docs.docker.com/get-docker/) - Optional, only if you need the backend locally

Detailed setup process of individual components is documented in our central repository [here](https://github.com/GaloyMoney/galoy/blob/main/docs/DEVELOPMENT_ENVIRONMENT.md).

## Project Setup

Once Nix and direnv are set up, follow these steps to set up the galoy-mobile project:

1. **Clone the Repository**: Clone the galoy-mobile repository to your local machine using Git.

```bash
git clone git@github.com:GaloyMoney/galoy-mobile.git
cd galoy-mobile
```

1. **Allow Direnv to run it's contents**:

```bash
direnv allow
```

This would download all of the dependencies needed to work with the Galoy Mobile.
This step sets up the NodeJS runtime, Android SDKs and creates the Emulator AVD for you in it's own separate chamber.
It also builds Ruby which is needed for some dependencies.
If you're on a Mac, it also lets you know if you're on an unsupported XCode version and gives you instructions on how to switch to a supported one.

1. **Install Node and Cocoapods(macOS) Dependencies**

```bash
yarn install
```

### Android Development

To run the application on Android:

1. **Start the Metro Development Server**:

- Run `yarn start` in one terminal window. If `yarn start` fails on the first run, restart the command as it's a known issue.

1. **Start the Emulator**:
- Run `make emulator` in one terminal. This starts the Android emulator. You can also BYOE (bring your own emulator) and run it from your Android Studio.

1. **Run the Application**:
- In another terminal, run `yarn android`. If you encounter "error Failed to launch emulator," it's expected and won't exit the android build. Our emulator device will still be available to the Android Debug Bridge (adb).

If while running the app on the emulator, `yarn start` crashes, then just restart it and rerun the application.

<details>
<summary>TMUX One Liner</summary>

```bash
tmux new-session -d -s mySession 'yarn start' \; split-window -h 'sleep 3 && yarn android' \; select-pane -t 0 \; split-window -v 'make emulator' \; attach-session -d -t mySession
```

</details>

### iOS Development (Mac Only)

To run the application on iOS:

1. **Xcode and Simulator Setup**:
- Make sure you have Xcode (and preferably on a version that direnv didn't complain to you about). If you don't you can download it using the `xcodes` CLI [see step](#xcode-and-simulator-setup-using-xcodes).
- Make sure you have an XCode Simulator Runtime. You probably have it if you had XCode installed previously but you can verify it by running `open -a simulator`. If it fails, you probably don't have it and you can download it using `xcodes` as well [see step](#xcode-and-simulator-setup-using-xcodes).

1. **Start the Metro Development Server**:

- Run `yarn start` in one terminal window.

1. **Run the Application**:
- Run `yarn ios` to start the application on iOS.

<details>
<summary>TMUX One Liner</summary>

```bash
tmux new-session -d -s mySession 'yarn start' \; split-window -h 'yarn ios' \; attach-session -d -t mySession
```

</details>

### Happy Coding 🧑‍💻✨

---

##### XCode and Simulator Setup using xcodes

You can download XCode and Simulator blazingly fast and let the CLI do all of the set up for you hassle free.
Here are the commands that do it:

```bash
xcodes install 15.3 # Or whatever version direnv tells you about
xcodes runtimes install "iOS 17.4" # Or the latest iOS out there
```

Xcodes install for the first time prompts you for Apple ID and Password. This is because Apple's license for XCode prohibits distribution of XCode from other servers than their own. And downloads from it can only work if you are authenticated. Hence, to use XCode, you need an Apple ID.
Loading
Loading