How to create a React Native app (3)? Setup packages

Setup package.json

  • How to clean up everything and restart metro?
  "scripts": {
    "reset": "rm yarn.lock; rm -rf android/app/build; rm -rf ios/build/; rm -rf node_modules; yarn install; cd ios; pod install --repo-update; cd ..; cd android; ./gradlew clean; cd ..; watchman watch-del-all; yarn start --reset-cache",
    ...
  }
  • How to restart metro?
  "scripts": {
    "restart": "yarn install; cd ios; pod install; cd ..; cd android; ./gradlew clean; cd ..; watchman watch-del-all; yarn start --reset-cache",
    ...
  }
  • How to build bundle file for Android apk build?
  "scripts": {
    "bundle-android": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res",
    ...
  }
  • How to run ios specific simulator and device?
  "scripts": {
    "ios:simulator": "react-native run-ios --simulator \"iPhone 8\"",
    "ios:device": "react-native run-ios --device \"hung's iPhone\"",
    "ios:ipad": "react-native run-ios '--simulator=iPad (5th generation)'",
    ...
  }
  • How to solve conflicted dependency version
    • Open yarn.lock file and search for duplicated dependency
    • Force package use the same dependency version that you want
  "resolutions": {
    "react-native-picker-select/@react-native-picker/picker": "2.1.0"
  },

What necessary packages you need to use?

Remove console.log

babel-plugin-transform-remove-console

Release JS bundle via CodePush

Fix package

How to build apk and TestFlight?

Automation build

  • Use AppCenter or Bitrise
Manual build
  • Use XCode to export ipa file, then use Transporter app to release to TestFlight
  • Use CLI to export apk file

How to debug your app on devices?

Android

Be the first to comment

Leave a Reply

Your email address will not be published.


*