amela-expo-template v1.0.0
Config và Build với EAS
1. Init project
Chạy command sau để init project:
npx create-expo-app app-name --template https://github.com/ngotheky/expo-template
Với app-name
là tên project. Ví dụ:
npx create-expo-app my-app --template https://github.com/ngotheky/expo-template
2. Tạo App và File .env
Tạo 3 App trên Expo Dev
Tạo 3 app trên Expo Dev, mỗi môi trường (development, staging, production) tạo một app riêng.
- Lý do: Expo giới hạn mỗi project chỉ được build 30 lần/tháng, nên việc tách app giúp môi trường development không ảnh hưởng đến các môi trường khác.
Cấu hình Biến Môi Trường
Điền các thông tin sau vào file .env
tương ứng với từng môi trường:
APP_NAME
SLUG
EXPO_PROJECT_ID
EAS_UPDATE_URL
Lưu ý:
- Expo sẽ tự động sinh ra folder iOS và Android trên server build.
- Khi đổi tên app, cần tạo lại app mới để tránh lỗi khi build.
3. Config Build
Cho iOS
Build với Account Apple Developer
- Khi chạy script build, đăng nhập vào account Apple Developer để sử dụng credential từ tài khoản.
Build với Credential Local
Copy file
certificate.p12
và file.mobileprovision
vào thư mụccredentials
.Thêm đường dẫn và password của certificate vào file
credentials.json
.Chạy script
build-local-credential-ios
để build iOS sử dụng credential local.
Cho Android
- Chạy script
generate-keychain-prod
. - Select platform
Android
. - Chọn profile
production
. - Chọn
Keystore: Manage everything needed to build your project
. - Chọn
Set up a new keystore
và bấm enter để tạo keystore. - Sau khi tạo xong bấm enter, chọn
Go back
để quay lại menucredentials
. - Chọn
credentials.json: Upload/Download credentials between EAS servers and your local json
. - Chọn
Download credentials from EAS to credentials.json
để tải keystore về, keystore sẽ tự động thêm vào foldercredentials
và cũng tự update thông tin vào filecredentials.json
. - Bấm enter để quay lại menu, chọn
Upload credentials from credentials.json to EAS
để upload keystore lên EAS.
4. Config Auto Submit
Cho Android
- Truy cập Google Cloud Console.
- Vào mục IAM & Admin > Service Account > Create Service Account.
- Điền thông tin vào form để tạo service account.
- Ở mục Grant this service account access to project, chọn role: - Service Accounts > Service Account User.
Tạo Key
Chọn Menu Actions > Manage Keys.
Chọn Add Key > Create Key.
Đổi tên file JSON tải về thành
play-store.json
, đặt vào thư mục gốc dự án.Copy email service account.
Vào Google Play Console, mời email với vai trò admin.
Chạy script
build-and-submit-android-prod
để submit app lên Internal Test (có thể điều chỉnh trongeas.json
).
Lưu ý:
- Submit thủ công một bản đầu tiên trước khi sử dụng EAS submit.
Cho iOS
Chỉnh sửa thông tin account build trong file
eas.json
.Chạy script
build-and-submit-ios-prod
để submit app lên Testflight.
6 months ago