Các câu lệnh hướng dẫn build ứng dụng
React Native trên IOS và ANDROID
(for Newbie)
1. Android
- Chạy debug (run with debug on devices for test)
- Chạy debug (run with debug on devices for test)
npx react-native run-android
- Chạy release (run with release on devices for test)
react-native run-android --variant=release
- Generate APK
cd ./android && ./gradlew assembleRelease
- Generate Release Bundle (file .aab):
cd ./android && ./gradlew bundleRelease
=> Quick command
- cd ./android && ./gradlew assembleRelease && cd ..
- cd ./android && ./gradlew bundleRelease && cd ..
- Reactotron - debug tool
- Reactotron - debug tool
- Tool support working with React Native + Redux
- Connect to Android Studio's Emulators: adb reverse tcp:9090 tcp:9090
- Connect to genyMotion emulator: adb reverse tcp:3334 tcp:3334
- Release via CodePush
- appcenter codepush release-react -a ten-project-android-tren-codepush -d Production -m true
- appcenter codepush release-react -a ten-project-android-tren-codepush -d Staging -m true
2. Ios- Chạy trên máy ảo (run on simulator)
- Chạy trên máy ảo (run on simulator)
npx react-native run-ios
- Chạy trên 1 máy ảo cụ thể (run on any simulator - example with Iphone 8)
- Chạy trên 1 máy ảo cụ thể (run on any simulator - example with Iphone 8)
- Cách 1: chạy câu lệnh
npx react-native run-ios —simulator=“iPhone 8”
- Cách 2: chọn trên Xcode
Mở file .xcworkspace (trong folder ios) của project của bạn. Có thể chọn devices hoặc simulators như hình dưới đây:
Sau đó sẽ hiện 1 list các devices hoặc simulators để chọn:
- Chạy với 1 cổng bất kì (run on specific port)
- Chạy với 1 cổng bất kì (run on specific port)
- react-native start --port=8088
- react-native run-ios --port=8088
- Chạy trên máy thật debug/release (run on real devices iphone)
Để có thể build app debug hoặc release trên hệ điều hành ios thì bạn làm theo các bước sau. Vào Xcode chọn Product > Scheme > Edit scheme ... - Chạy trên máy thật debug/release (run on real devices iphone)
Sau khi làm sẽ hiển thị 1 cửa sổ như trên, chọn Debug hoặc Release ở phần Build Confiuration
Sau khi làm sẽ hiển thị 1 cửa sổ như trên, chọn Debug hoặc Release ở phần Build Confiuration
Trên đây là bài viết về một số câu lệnh để có thể build ứng dụng trên android và ios cho các bạn mới chưa biết. Nếu có gì sai sót mong các bạn góp ý tại kênh fb của mình để mình có thể hoàn thiện bài viết tốt hơn nhé <3