Files
notesnook/apps/mobile/README.md

162 lines
4.0 KiB
Markdown
Raw Permalink Normal View History

2022-08-31 19:04:38 +05:00
<p align="center">
<img style="align:center; border-radius: 20px;" src="/resources/screenshots/mobile.jpg" alt="Notesnook mobile screenshot" width="250" />
</p>
2022-08-16 16:48:10 +05:00
2022-08-31 19:04:38 +05:00
<h1 align="center">Notesnook Mobile</h1>
2026-02-27 08:47:20 +05:00
<h3 align="center">The mobile app is built with React Native for both iOS and Android.</h3>
<p align="center"><a href="#build-instructions">Build instructions</a> | <a href="#developer-guide">Developer guide</a> | <a href="#running-e2e-tests-detox">E2E tests</a></p>
2022-08-16 16:48:10 +05:00
2022-08-31 19:04:38 +05:00
<p align="center">
<a href="https://play.google.com/store/apps/details?id=com.streetwriters.notesnook">
<img alt="Download on Google Play" src="https://play.google.com/intl/en_us/badges/images/badge_new.png" height=43>
</a>
<a href="https://apps.apple.com/us/app/notesnook-take-private-notes/id1544027013">
<img alt="Download on App Store" src="https://user-images.githubusercontent.com/7317008/43209852-4ca39622-904b-11e8-8ce1-cdc3aee76ae9.png" height=43>
</a>
</p>
2022-08-16 16:48:10 +05:00
2022-08-31 19:04:38 +05:00
## Build instructions
2022-08-16 16:48:10 +05:00
> **Before you start, it is recommended that you read [the contributing guidelines](/CONTRIBUTING.md).**
2022-08-16 16:48:10 +05:00
### Setting up the development environment
2022-08-16 16:48:10 +05:00
2022-08-31 19:04:38 +05:00
Requirements:
2022-08-16 16:48:10 +05:00
2026-02-27 08:47:20 +05:00
1. [Node.js](https://nodejs.org/en/download/) 20+ (the repo is pinned to Node `22.20.0` via Volta)
2022-08-31 19:04:38 +05:00
2. [git](https://git-scm.com/downloads)
2026-02-27 08:47:20 +05:00
3. `npm`
4. [React Native environment setup](https://reactnative.dev/docs/set-up-your-environment)
2022-08-16 16:48:10 +05:00
2026-02-27 08:47:20 +05:00
To run the app locally, first complete React Native native tooling setup:
2022-08-16 16:48:10 +05:00
2026-02-27 08:47:20 +05:00
1. Open [React Native environment setup](https://reactnative.dev/docs/set-up-your-environment)
2022-08-31 19:04:38 +05:00
2. Select `React Native CLI Quickstart`
2026-02-27 08:47:20 +05:00
3. Select your OS and target platform(s): iOS and/or Android
2022-08-31 19:04:38 +05:00
4. Follow the steps listed.
2022-08-16 16:48:10 +05:00
2026-02-27 08:47:20 +05:00
> Expo is not used in this project.
2022-08-16 16:48:10 +05:00
2026-02-27 08:47:20 +05:00
Clone the monorepo:
2022-08-17 13:16:59 +05:00
2022-08-31 19:04:38 +05:00
```bash
git clone https://github.com/streetwriters/notesnook.git
2022-08-17 13:16:59 +05:00
2022-08-31 19:04:38 +05:00
# change directory
cd notesnook
```
2022-08-17 13:16:59 +05:00
2026-02-27 08:47:20 +05:00
Install dependencies and bootstrap the mobile workspace:
2022-08-17 13:16:59 +05:00
```bash
2022-08-31 19:04:38 +05:00
# this might take a while to complete
npm install
2026-02-26 12:46:53 +05:00
npm run bootstrap -- --scope=mobile
2022-08-17 13:16:59 +05:00
```
2022-08-31 19:04:38 +05:00
### Running the app on Android
2026-02-27 08:47:20 +05:00
[Set up an Android emulator from Android Studio](https://developer.android.com/studio/run/managing-avds) (or connect a physical device), then run:
2022-08-17 13:16:59 +05:00
```bash
2022-08-31 19:04:38 +05:00
npm run start:android
2022-08-17 13:16:59 +05:00
```
2026-02-27 08:47:20 +05:00
If you are using a physical device, enable [USB debugging](https://developer.android.com/studio/debug/dev-options).
2022-08-17 13:16:59 +05:00
2022-08-31 19:04:38 +05:00
### Running the app on iOS
2022-08-17 13:16:59 +05:00
2026-02-27 08:47:20 +05:00
Install CocoaPods dependencies first, then run the iOS app:
2022-08-17 13:16:59 +05:00
```bash
2022-08-31 19:04:38 +05:00
# this might take a while to complete
npm run prepare:ios
npm run start:ios
2022-08-17 13:16:59 +05:00
```
2026-02-27 08:47:20 +05:00
### Useful development commands
```bash
# start Metro only
npm run start:metro
# start Re.Pack bundler
npm run start:repack
```
2022-08-31 19:04:38 +05:00
## Developer guide
2022-08-17 13:16:59 +05:00
2026-02-27 08:47:20 +05:00
> The mobile app is a mixed TypeScript/JavaScript codebase.
2022-08-17 15:59:59 +05:00
2022-08-31 19:04:38 +05:00
### The tech stack
2022-08-17 15:59:59 +05:00
We try to keep the stack as lean as possible:
2022-08-17 13:16:59 +05:00
2026-02-27 08:47:20 +05:00
1. React Native `0.82`
2. React `19`
3. TypeScript + JavaScript
4. Zustand (state management)
5. Detox (end-to-end testing)
6. libsodium (encryption)
2022-08-17 13:16:59 +05:00
2022-08-31 19:04:38 +05:00
### Project structure
2022-08-17 13:16:59 +05:00
2026-02-27 08:47:20 +05:00
Top-level directories in `apps/mobile/`:
2022-08-17 13:16:59 +05:00
2026-02-27 08:47:20 +05:00
- `app/`: Main React Native app source (`components`, `common`, `hooks`, `navigation`, `screens`, `services`, `stores`, `utils`, etc.)
- `android/`: Android native project
- `ios/`: iOS native project
- `e2e/`: Detox test suite and config
- `patches/`: `patch-package` patches
- `scripts/`: Mobile-specific scripts
2022-08-17 15:59:59 +05:00
2026-02-27 08:47:20 +05:00
## Running E2E tests (Detox)
2022-08-17 13:16:59 +05:00
2026-02-27 08:47:20 +05:00
Detox device defaults in this repo:
2022-08-31 19:04:38 +05:00
2026-02-27 08:47:20 +05:00
- Android emulator: `Pixel_5_API_36`
- iOS simulator: `iPhone 17 Pro Max`
2022-09-01 15:43:24 +05:00
### Android
2026-02-27 08:47:20 +05:00
Build and run Android Detox tests:
2022-09-01 15:43:24 +05:00
2026-02-27 08:47:20 +05:00
```bash
2022-09-01 15:43:24 +05:00
npm run build:android
2026-02-27 08:47:20 +05:00
npm run test:android
2022-09-01 15:43:24 +05:00
```
2026-02-27 08:47:20 +05:00
For debug configuration:
2022-09-01 15:43:24 +05:00
2026-02-27 08:47:20 +05:00
```bash
npm run build:android:debug
npm run start:metro
npm run test:android:debug
2022-09-01 15:43:24 +05:00
```
### iOS
2026-02-27 08:47:20 +05:00
Build and run iOS Detox tests:
2022-09-01 15:43:24 +05:00
2026-02-27 08:47:20 +05:00
```bash
npm run build:ios
npm run test:ios
2022-09-01 15:43:24 +05:00
```
2026-02-27 08:47:20 +05:00
If simulator tooling is missing, install [AppleSimulatorUtils](https://github.com/wix/AppleSimulatorUtils):
```bash
2022-09-01 15:43:24 +05:00
brew tap wix/brew
brew install applesimutils
```
2026-02-27 08:47:20 +05:00
## Release commands
2022-09-01 15:43:24 +05:00
2026-02-27 08:47:20 +05:00
Android release helpers:
2022-09-01 15:43:24 +05:00
2026-02-27 08:47:20 +05:00
```bash
npm run release:android
npm run release:android:bundle
2022-09-01 15:43:24 +05:00
```