diff --git a/apps/mobile/app.config.js b/apps/mobile/app.config.js index 2d4dd361d..5cac99da3 100644 --- a/apps/mobile/app.config.js +++ b/apps/mobile/app.config.js @@ -1,8 +1,17 @@ +const IS_DEV = process.env.APP_VARIANT === "development"; + export default { expo: { - name: "Karakeep", + ...(IS_DEV + ? { + name: "Karakeep (Dev)", + scheme: "karakeep-dev", + } + : { + name: "Karakeep", + scheme: "karakeep", + }), slug: "hoarder", - scheme: "karakeep", version: "1.9.1", orientation: "portrait", icon: { @@ -16,7 +25,9 @@ export default { assetBundlePatterns: ["**/*"], ios: { supportsTablet: true, - bundleIdentifier: "app.hoarder.hoardermobile", + bundleIdentifier: IS_DEV + ? "app.hoarder.hoardermobile.dev" + : "app.hoarder.hoardermobile", splash: { image: "./assets/splash.png", resizeMode: "contain", @@ -53,7 +64,9 @@ export default { backgroundColor: "#000000", }, }, - package: "app.hoarder.hoardermobile", + package: IS_DEV + ? "app.hoarder.hoardermobile.dev" + : "app.hoarder.hoardermobile", versionCode: 36, }, plugins: [ diff --git a/apps/mobile/eas.json b/apps/mobile/eas.json index 0897755db..0e87e83c1 100644 --- a/apps/mobile/eas.json +++ b/apps/mobile/eas.json @@ -6,7 +6,10 @@ "build": { "development": { "developmentClient": true, - "distribution": "internal" + "distribution": "internal", + "env": { + "APP_VARIANT": "development" + } }, "preview": { "distribution": "internal" diff --git a/apps/mobile/package.json b/apps/mobile/package.json index 16f8637eb..876c040c0 100644 --- a/apps/mobile/package.json +++ b/apps/mobile/package.json @@ -4,9 +4,15 @@ "main": "index.ts", "scripts": { "clean": "git clean -xdf .expo .turbo node_modules", + "clean:prebuild": "APP_VARIANT=development expo prebuild --no-install --clean", + "expo": "expo", "start": "expo start", - "android": "expo run:android", - "ios": "expo run:ios", + "android": "APP_VARIANT=development expo run:android", + "android:preview": "APP_VARIANT=development pnpm run android --variant release", + "android:release": "pnpm run android --variant release", + "ios": "APP_VARIANT=development expo run:ios", + "ios:preview": "APP_VARIANT=development pnpm run ios --configuration Release", + "ios:release": "pnpm run ios --configuration Release", "web": "expo start --web", "format": "oxfmt --check .", "format:fix": "oxfmt .", diff --git a/docs/docs/08-development/01-setup.md b/docs/docs/08-development/01-setup.md index 1c98a6751..87f145d31 100644 --- a/docs/docs/08-development/01-setup.md +++ b/docs/docs/08-development/01-setup.md @@ -121,7 +121,7 @@ The worker app will automatically start headless chrome on startup for crawling To build and run the mobile app locally, you'll need: - **For iOS development**: - - macOS computer + - macOS - Xcode installed from the App Store - iOS Simulator (comes with Xcode) @@ -132,27 +132,45 @@ To build and run the mobile app locally, you'll need: For detailed setup instructions, refer to the [Expo documentation](https://docs.expo.dev/guides/local-app-development/). -#### Running the app +#### Updating from an Older Version -- `cd apps/mobile` -- `pnpm exec expo prebuild --no-install` to build the app. +If you are returning to mobile development after a significant update to the source (e.g. Expo version bump or major dependency changes), the build may fail with stale artifacts in workspace `node_modules`. Run a clean wipe before reinstalling: -**For iOS:** -- `pnpm exec expo run:ios` -- The app will be installed and started in the simulator. - -**Troubleshooting iOS Setup:** -If you encounter an error like `xcrun: error: SDK "iphoneos" cannot be located`, you may need to set the correct Xcode developer directory: ```bash -sudo xcode-select -s /Applications/Xcode.app/Contents/Developer +pnpm run clean:workspaces +pnpm install +pnpm --filter @karakeep/mobile clean:prebuild +``` + +Then continue with the prebuild and run steps below. + +#### Quick Start + +```sh +# ios +pnpm ios + +# android +pnpm android ``` -**For Android:** -- Start the Android emulator or connect a physical device. -- `pnpm exec expo run:android` -- The app will be installed and started on the emulator/device. +More details below if you want to understand what's going on. + + +#### Details + +The app has three variants: development, preview, and release. + +| Variant | Description | Expo Dev Tools | Command (iOS) | Command (Android) | +|---------|-------------|----------------|---------------|--------------------| +| Development (default) | Requires the expo devserver to be running. Uses a separate bundle ID so it can be installed alongside the production app. | Yes | `pnpm ios` | `pnpm android` | +| Preview | Standalone app that doesn't require the expo devserver. Uses its own bundle ID. | No | `pnpm --filter @karakeep/mobile ios:preview` | `pnpm --filter @karakeep/mobile android:preview` | +| Release | Standalone app using the production bundle ID. Closest to a production build. | No | `pnpm --filter @karakeep/mobile ios:release` | `pnpm --filter @karakeep/mobile android:release` | + +In 90% of the cases, you'll want to use the development variant. + +Note: Changing the code will hot reload the app. However, installing new packages requires restarting the expo server. -Changing the code will hot reload the app. However, installing new packages requires restarting the expo server. ### Browser Extension diff --git a/package.json b/package.json index c01ebc165..168a51acf 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,8 @@ "db:studio": "pnpm --filter @karakeep/db studio", "workers": "pnpm --filter @karakeep/workers run start", "web": "pnpm --filter @karakeep/web run dev", + "android": "pnpm --filter @karakeep/mobile android", + "ios": "pnpm --filter @karakeep/mobile ios", "prepare": "husky", "format": "turbo --no-daemon format --continue", "format:fix": "turbo --no-daemon format:fix --continue",