This app demonstrates how to use react-native-image-code-scanner in an Expo project.
- Pick image from camera or gallery (
expo-image-picker) - Select barcode formats before scanning
- Scan with automatic preprocessing (built into the library)
- Show scan results and execution time
- Node.js
>=18 - Yarn
3.6.1via Corepack - iOS: Xcode (for native build)
- Android: Android Studio + SDK (for native build)
Use Yarn for this workspace. Do not mix npm installs with the generated native projects.
From the repository root:
yarn installRun Metro from the example folder:
yarn expo start --clear --dev-client --host localhost- Press
ifor iOS simulator. - Press
afor Android emulator. - If the app was opened before Metro started, terminate the app and open it again from Metro.
- JS/TSX changes use Fast Refresh. Native, Podfile, Gradle, or architecture changes require rebuild.
app.json is the source of truth:
{
"expo": {
"newArchEnabled": true
}
}After changing this value, run prebuild --clean and rebuild the native app.
Clean regenerate iOS and build:
cd example
yarn expo prebuild --clean --platform ios
yarn expo run:ios --no-build-cacheWith Metro running in another terminal:
cd example
yarn expo run:ios --no-bundler --no-build-cacheVerify New Architecture:
cat ios/Podfile.properties.json
# expect: "newArchEnabled": "true"Clean regenerate Android and build:
cd example
yarn expo prebuild --clean --platform android
yarn expo run:android --no-build-cacheWith Metro running in another terminal:
cd example
yarn expo run:android --no-bundler --no-build-cacheVerify New Architecture:
grep newArchEnabled android/gradle.properties
# expect: newArchEnabled=true- Preprocessing options are configurable in the UI: contrast, grayscale, rotations.
- At least one barcode format must stay selected.
- Permissions for camera and media library are requested at runtime.
- Expo Go is not enough for scanning because this package uses native modules.
- White screen: Metro is probably not running or the app opened before Metro. Start Metro, terminate the app, then press
i/a. - No Fast Refresh: confirm
http://127.0.0.1:8081/statusworks and open the app from Metro. - iOS native issue after config changes: run
yarn expo prebuild --clean --platform ios. - Android native issue after config changes: run
yarn expo prebuild --clean --platform android. - Metro cache issue: run
yarn expo start --clear --dev-client --host localhost.
yarn start: Start Expo dev serveryarn ios: Build and run on iOSyarn android: Build and run on Androidyarn prebuild: Generate native projectsyarn prebuild:clean: Regenerate native projects from scratch