Skip to content

Instantly share code, notes, and snippets.

@iegik
Last active February 4, 2023 10:51
Show Gist options
  • Save iegik/36266a433c5fd4b30ddc803db94a325f to your computer and use it in GitHub Desktop.
Save iegik/36266a433c5fd4b30ddc803db94a325f to your computer and use it in GitHub Desktop.

Expo

For now - default configuration for React Native: expo.io

Package naming: com.[company].[appname]

Environment info

npx expo-env-info

Get Started

npx create-expo-app --template

Install

This APP can only be used in a secure environment (https). You can use expo npx start:web --https

npm i
EXPO_DEVTOOLS_LISTEN_ADDRESS=[local-ip] expo r -c

Dependencies

npx expo install expo-camera expo-barcode-scanner

Deployment

  1. Create own .env file
  2. Deploy

Web (using Vercel)

npm build:web # first build to create web-build folder to .vercel configuration there
cd web-build
npx vercel init
cp -r .vercel ..
npm build:web
cp -r .vercel web-build/
npx vercel --prod web-build
one-liners npx expo build:web && cp -r .vercel web-build && npx vercel --prod web-build

EAS

https://expo.dev/pricing

npm install -g eas-cli

Android

eas build -p android
adb usb
adb push *.aab /sdcard/

iOS

eas build -p ios
xcrun simctl install booted build/ios/build/Debug-iphonesimulator/*.app

Analytics and optimization

mkdir -p reports && npx lighthouse http://localhost:19006/ --view --output=json --output-path=./reports/lighthouse-results.json --save-assets

https://googlechrome.github.io/lighthouse/viewer/

Optimize for production

npx expo-optimize

Playground

Deep links in Expo:

Deep link: [scheme]://[in-app-uri] Example: myapp://foo?bar=baz

exp://127.0.0.1:19000/--/[in-app-uri]
exp://localhost:19000/--/[in-app-uri]
exp://[local-ip]:19000/--/[in-app-uri]
exp://u.expo.dev/[project-id]/--/[in-app-uri]
more exp://u.expo.dev/[project-id]?channel-name=[channel-name]&runtime-version=[runtime-version]/--/[in-app-uri]

Where: channel-name=default runtime-version=ios.runtimeVersion | android.runtimeVersion | runtimeVersion within app.json

deeplink "exp://`ip`:19000/--/foo"
more adb shell am start -a android.intent.action.VIEW -d "[scheme]://[in-app-uri]" com.[company].[appname]

adb shell am start -a android.intent.action.VIEW -d "exp://127.0.0.1:19000/--/[in-app-uri]" host.exp.exponent xcrun simctl openurl booted 'exp://127.0.0.1:19000/--/Payment'

Watchman

Fix permissions:

sudo chmod 2777 /usr/local/var/run/watchman
sudo rm -rf /usr/local/var/run/watchman/*

Restart server

watchman watch-del-all
watchman shutdown-server
rm -rf /var/run/watchman/$USER-state/
watchman --foreground --logfile=/dev/stdout --no-pretty get-sockname
watchman watch-del-all && 
rm -rf $TMPDIR/react-native-packager-cache-* &&
rm -rf $TMPDIR/metro-bundler-cache-*

Debugging

fingerprint

adb pubkey ~/.android/adbkey | awk '{print $1}' \
| openssl base64 -A -a -d | openssl md5 -c | tr a-z A-Z

View log messages of React Native

adb logcat -s ReactNative:V ReactNativeJS:V PackageManager:V AndroidRuntime:V

Dump resource id index from APK

W/ResourceType( 6139): For resource 0x0101053d, entry index(1341) is beyond type entryCount(1155)

aapt dump --values resources myAPK.apk > c:\my-res.txt

There is no differrences between .keystore and .jks

Detox

https://wix.github.io/Detox/docs/introduction/getting-started/

npm install --global detox-cli
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment