-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat(mobile): add APP_VARIANT to make it easier to install multiple variants #2422
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,9 +4,14 @@ | |
| "main": "index.ts", | ||
| "scripts": { | ||
| "clean": "git clean -xdf .expo .turbo node_modules", | ||
| "clean:prebuild": "expo prebuild --no-install --clean", | ||
| "clean:prebuild:dev": "APP_VARIANT=development pnpm run clean:prebuild", | ||
| "expo": "expo", | ||
| "start": "expo start", | ||
| "android": "expo run:android", | ||
| "android:dev:release": "APP_VARIANT=development pnpm run android --variant release", | ||
|
Comment on lines
+8
to
+12
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, let's check the full package.json to see dependencies and all scripts
cat apps/mobile/package.jsonRepository: karakeep-app/karakeep Length of output: 3232 🏁 Script executed: # Search for other environment variable assignments in scripts across the codebase
rg "APP_VARIANT|cross-env" --type json -A 2 -B 2Repository: karakeep-app/karakeep Length of output: 974 🏁 Script executed: # Check if there's documentation about Windows/platform support
fd -t f -e md | xargs grep -l "Windows\|platform\|cmd\.exe\|PowerShell" | head -20Repository: karakeep-app/karakeep Length of output: 731 🏁 Script executed: # Look for similar cross-platform script patterns in other package.json files
fd -name "package.json" -type f | xargs grep -l "cross-env\|env\s" | head -10Repository: karakeep-app/karakeep Length of output: 295 🏁 Script executed: # Check the development setup documentation
fd -name "setup.md" -o -name "*development*" -type f | grep -E "(docs|markdown)" | head -10Repository: karakeep-app/karakeep Length of output: 295 🏁 Script executed: # Read environment variables documentation
cat docs/docs/03-configuration/01-environment-variables.mdRepository: karakeep-app/karakeep Length of output: 49842 🏁 Script executed: # Search for Windows or platform-related content in development docs
find docs -name "*.md" -type f | xargs grep -l "Windows\|windows\|cmd\.exe\|PowerShell\|platform" 2>/dev/null | head -5Repository: karakeep-app/karakeep Length of output: 293 🏁 Script executed: # Check if there are other npm scripts that handle environment variables or shell commands
rg "pnpm run|npm run" apps/mobile/package.json -A 1 -B 1Repository: karakeep-app/karakeep Length of output: 375 🏁 Script executed: # Check if other workspaces use cross-env or similar patterns
find . -name "package.json" -type f | xargs grep -l "cross-env" 2>/dev/nullRepository: karakeep-app/karakeep Length of output: 49 Add cross-env to handle Windows shells in dev-variant scripts.
Suggested approach
Alternatively, if Windows support is not required for mobile development, document this constraint explicitly. 🤖 Prompt for AI Agents |
||
| "ios": "expo run:ios", | ||
| "ios:dev:release": "echo 'i dont have an ios device to confirm if this works'", | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. heads up, i haven't tested it on ios ^^ |
||
| "web": "expo start --web", | ||
| "format": "oxfmt --check .", | ||
| "format:fix": "oxfmt .", | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -132,27 +132,98 @@ 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/). | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| #### Updating from an Older Version | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| 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: | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||
| pnpm run clean:workspaces | ||||||||||||||||||||||||||||
| pnpm install | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Then continue with the prebuild and run steps below. | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| #### TLDR??? THIS IS TOO VERBOSE! | ||||||||||||||||||||||||||||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if this language is too casual we can change this lol |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ```sh | ||||||||||||||||||||||||||||
| # ios | ||||||||||||||||||||||||||||
| pnpm --filter mobile clean:prebuild:dev && APP_VARIANT=development pnpm ios | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # android | ||||||||||||||||||||||||||||
| pnpm --filter mobile clean:prebuild:dev && APP_VARIANT=development pnpm android | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| More details below if you want to understand what's going on | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
Comment on lines
+146
to
+157
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider simplifying the TLDR heading tone Line 135 ( Suggested wording-#### TLDR??? THIS IS TOO VERBOSE!
+#### TL;DR📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
| #### Running the app | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| - `cd apps/mobile` | ||||||||||||||||||||||||||||
| - `pnpm exec expo prebuild --no-install` to build the app. | ||||||||||||||||||||||||||||
| There are two steps: **prebuild** (generates native project files) and **run** (builds and launches the app). | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| **Step 1: Prebuild** | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Basic prebuild: | ||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||
| pnpm --filter mobile expo prebuild --no-install | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| If you need a clean rebuild (e.g. after changing the bundleIdentifier/package), add `--clean`: | ||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||
| pnpm --filter mobile expo prebuild --no-install --clean | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Or use the shorthand alias: | ||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||
| pnpm --filter mobile clean:prebuild | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| To run a **dev variant** alongside your production Karakeep app (without uninstalling it), set `APP_VARIANT=development` during a clean prebuild. This changes the bundleIdentifier/package so both versions can coexist: | ||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||
| APP_VARIANT=development pnpm --filter mobile expo prebuild --no-install --clean | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Or use the shorthand alias: | ||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||
| pnpm --filter mobile clean:prebuild:dev | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| > **Note:** The installed app expects the dev server to be available and accessible. | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| **Step 2: Run** | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| **For iOS:** | ||||||||||||||||||||||||||||
| - `pnpm exec expo run:ios` | ||||||||||||||||||||||||||||
| - The app will be installed and started in the simulator. | ||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||
| pnpm ios | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
| The app will be installed and started in the simulator. | ||||||||||||||||||||||||||||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
193
to
+197
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Android section (lines 211–214) correctly notes that Add a note after the basic
Suggested change
The app will be installed and started in the simulator. If you prebuilt with APP_VARIANT=development pnpm iosThe app will be installed and started in the simulator. If you prebuilt with APP_VARIANT=development pnpm ios |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| **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: | ||||||||||||||||||||||||||||
| If you encounter `xcrun: error: SDK "iphoneos" cannot be located`, set the correct Xcode developer directory: | ||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||
| sudo xcode-select -s /Applications/Xcode.app/Contents/Developer | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| **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. | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Changing the code will hot reload the app. However, installing new packages requires restarting the expo server. | ||||||||||||||||||||||||||||
| Start the Android emulator or connect a physical device, then: | ||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||
| pnpm android | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| If you prebuilt with `APP_VARIANT=development`, make sure to pass it at run time too: | ||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||
| APP_VARIANT=development pnpm android | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Changing code will hot reload the app. However, installing new packages requires restarting the expo server. | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| **Installing a release build (Android only):** | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| > **Note:** This may also work for iOS, but has not been confirmed due to lack of an iOS test device (of this author). | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| To install the dev variant as a release build (no dev server required): | ||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||
| pnpm --filter mobile clean:prebuild:dev | ||||||||||||||||||||||||||||
| pnpm --filter mobile android:dev:release | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ### Browser Extension | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fail fast on unsupported
APP_VARIANTvalues.Line 1 silently maps anything except
"development"to the production identifiers. A typo likedevordevelopementwould prebuildapp.hoarder.hoardermobileand can overwrite the installed prod app, which is the opposite of the side-by-side install goal here.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents