mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1# Build instructions
2
3## App Build
4
5- Set up your environment [using the react native instructions](https://reactnative.dev/docs/environment-setup).
6- If you're running macOS, make sure you are running the correct versions of Ruby and Cocoapods:
7 - Check if you've installed Cocoapods through `homebrew`. If you have, remove it:
8 - `brew info cocoapods`
9 - If output says `Installed`:
10 - `brew remove cocoapods`
11 - If you have not installed `rbenv`:
12 - `brew install rbenv`
13 - `rbenv install 2.7.6`
14 - `rbenv global 2.7.6`
15 - Add `eval "$(rbenv init - zsh)"` to your `~/.zshrc`
16 - From inside the project directory:
17 - `bundler install`
18- Setup your environment [for e2e testing using detox](https://wix.github.io/Detox/docs/introduction/getting-started):
19 - `yarn global add detox-cli`
20 - `brew tap wix/brew`
21 - `brew install applesimutils`
22- After initial setup:
23 - Copy `google-services.json.example` to `google-services.json` or provide your own `google-services.json`. (A real firebase project is NOT required)
24 - `npx expo prebuild` -> you will also need to run this anytime `app.json` or native `package.json` deps change
25 - `yarn intl:build` -> you will also need to run this anytime `./src/locale/{locale}/messages.po` change
26- Start the dev servers
27 - `git clone git@github.com:bluesky-social/atproto.git`
28 - `cd atproto`
29 - `brew install pnpm`
30 - `brew install jq`
31 - `pnpm i`
32 - `pnpm build`
33 - Start the docker daemon (on MacOS this entails starting the Docker Desktop app)
34 - Launch a Postgres database on port 5432
35 - `cd packages/dev-env && pnpm start`
36- Run the dev app
37 - iOS: `yarn ios`
38 - Xcode must be installed for this to run.
39 - A simulator must be preconfigured in Xcode settings.
40 - if no iOS versions are available, install the iOS runtime at `Xcode > Settings > Platforms`.
41 - In addition, ensure Xcode Command Line Tools are installed using `xcode-select --install`.
42 - Pods must be installed:
43 - From the project directory root: `cd ios && pod install`.
44 - Expo will require you to configure Xcode Signing. Follow the linked instructions. Error messages in Xcode related to the signing process can be safely ignored when installing on the iOS Simulator; Expo merely requires the profile to exist in order to install the app on the Simulator.
45 - Android: `yarn android`
46 - Web: `yarn web`
47- If you are cloning or forking this repo as an open-source developer, please check the tips below as well
48- Run e2e tests
49 - Start in various console tabs:
50 - `yarn e2e:mock-server`
51 - `yarn e2e:metro`
52 - Run once: `yarn e2e:build`
53 - Each test run: `yarn e2e:run`
54- Tips
55 - Copy the `.env.example` to `.env` and fill in any necessary tokens. (The Sentry token is NOT required; see instructions below if you want to enable Sentry.)
56 - To run on the device, add `--device` to the command (e.g. `yarn android --device`). To build in production mode (slower build, faster app), also add `--variant release`.
57 - If you want to use Expo EAS on your own builds without ejecting from Expo, make sure to change the `owner` and `extra.eas.projectId` properties. If you do not have an Expo account, you may remove these properties.
58 - `npx react-native info` Checks what has been installed.
59 - If the Android simulator frequently hangs or is very sluggish, [bump its memory limit](https://stackoverflow.com/a/40068396)
60 - The Android simulator won't be able to access localhost services unless you run `adb reverse tcp:{PORT} tcp:{PORT}`
61 - For instance, the locally-hosted dev-wallet will need `adb reverse tcp:3001 tcp:3001`
62 - For some reason, the typescript compiler chokes on platform-specific files (e.g. `foo.native.ts`) but only when compiling for Web thus far. Therefore we always have one version of the file that doesn't use a platform specifier, and that should be the Web version. ([More info](https://stackoverflow.com/questions/44001050/platform-specific-import-component-in-react-native-with-typescript).)
63
64### Adding Sentry
65
66Adding Sentry is NOT required. You can keep `SENTRY_AUTH_TOKEN=` in `.env` which will build the app without Sentry.
67
68However, if you're a part of the Bluesky team and want to enable Sentry, fill in `SENTRY_AUTH_TOKEN` in your `.env`. It can be created on the Sentry dashboard using [these instructions](https://docs.expo.dev/guides/using-sentry/#sign-up-for-a-sentry-account-and-create-a-project).
69
70If you change `SENTRY_AUTH_TOKEN`, you need to do `yarn prebuild` before running `yarn ios` or `yarn android` again.
71
72## Go-Server Build
73
74### Prerequisites
75
76- [Go](https://go.dev/)
77- [Yarn](https://yarnpkg.com/)
78
79### Steps
80
81To run the build with Go, use staging credentials, your own, or any other account you create.
82
83```
84cd social-app
85yarn && yarn build-web
86cp ./web-build/static/js/*.* bskyweb/static/js/
87cd bskyweb/
88go mod tidy
89go build -v -tags timetzdata -o bskyweb ./cmd/bskyweb
90./bskyweb serve --pds-host=https://staging.bsky.dev --handle=<HANDLE> --password=<PASSWORD>
91```
92
93On build success, access the application at [http://localhost:8100/](http://localhost:8100/). Subsequent changes require re-running the above steps in order to be reflected.
94
95## Various notes
96
97### Debugging
98
99- Note that since 0.70, debugging using the old debugger (which shows up using CMD+D) doesn't work anymore. Follow the instructions below to debug the code: https://reactnative.dev/docs/next/hermes#debugging-js-on-hermes-using-google-chromes-devtools
100
101### Developer Menu
102
103To open the [Developer Menu](https://docs.expo.dev/debugging/tools/#developer-menu) on an `expo-dev-client` app you can do the following:
104
105- Android Device: Shake the device vertically, or if your device is connected via USB, run adb shell input keyevent 82 in your terminal
106- Android Emulator: Either press Cmd ⌘ + m or Ctrl + m or run adb shell input keyevent 82 in your terminal
107- iOS Device: Shake the device, or touch 3 fingers to the screen
108- iOS Simulator: Press Ctrl + Cmd ⌘ + z on a Mac in the emulator to simulate the shake gesture or press Cmd ⌘ + d
109
110### Running E2E Tests
111
112- Make sure you've set your environment following the above
113- Make sure Metro and the dev server are running
114- Run `yarn e2e`
115- Find the artifacts in the `artifact` folder
116
117### Polyfills
118
119`./platform/polyfills.*.ts` adds polyfills to the environment. Currently, this includes:
120
121- TextEncoder / TextDecoder
122
123### Sentry sourcemaps
124
125Sourcemaps should automatically be updated when a signed build is created using `eas build` and published using `eas submit` due to the postPublish hook setup in `app.json`. However, if an update is created and published OTA using `eas update`, we need to take the following steps to upload sourcemaps to Sentry:
126
127- Run eas update. This will generate a dist folder in your project root, which contains your JavaScript bundles and source maps. This command will also output the 'Android update ID' and 'iOS update ID' that we'll need in the next step.
128- Copy or rename the bundle names in the `dist/bundles` folder to match `index.android.bundle` (Android) or `main.jsbundle` (iOS).
129- Next, you can use the Sentry CLI to upload your bundles and source maps:
130 - release name should be set to `${bundleIdentifier}@${version}+${buildNumber}` (iOS) or `${androidPackage}@${version}+${versionCode}` (Android), so for example `com.domain.myapp@1.0.0+1`.
131 - `dist` should be set to the Update ID that `eas update` generated.
132- Command for Android:
133 `node_modules/@sentry/cli/bin/sentry-cli releases \
134files <release name> \
135upload-sourcemaps \
136--dist <Android Update ID> \
137--rewrite \
138dist/bundles/index.android.bundle dist/bundles/android-<hash>.map`
139- Command for iOS:
140 `node_modules/@sentry/cli/bin/sentry-cli releases \
141files <release name> \
142upload-sourcemaps \
143--dist <iOS Update ID> \
144--rewrite \
145dist/bundles/main.jsbundle dist/bundles/ios-<hash>.map`
146
147### OTA updates
148
149To create OTA updates, run `eas update` along with the `--branch` flag to indicate which branch you want to push the update to, and the `--message` flag to indicate a message for yourself and your team that shows up on https://expo.dev. All the channels (which make up the options for the `--branch` flag) are given in `eas.json`. [See more here](https://docs.expo.dev/eas-update/getting-started/)
150
151The clients which can receive an OTA update are governed by the `runtimeVersion` property in `app.json`. Right now, it is set so that only apps with the same `appVersion` (same as `version` property in `app.json`) can receive the update and install it. However, we can manually set `"runtimeVersion": "1.34.0"` or anything along those lines as well. This is useful if very little native code changes from update to update. If we are manually setting `runtimeVersion`, we should increment the version each time the native code is changed. [See more here](https://docs.expo.dev/eas-update/runtime-versions/)