Mobile App Build Guide
This guide covers the build process for the TopsPizza mobile app using Ionic Capacitor for both Android and iOS platforms.
Prerequisites
Required Software
- Node.js (v14 or higher)
- npm or yarn
- Ionic CLI:
npm install -g @ionic/cli
- Capacitor CLI:
npm install -g @capacitor/cli
Android Development
- Android Studio with Android SDK
- Java Development Kit (JDK) 8 or higher
- Android SDK with API level 21+ (Android 5.0+)
- Gradle (usually bundled with Android Studio)
iOS Development (macOS only)
- Xcode (latest version recommended)
- CocoaPods:
sudo gem install cocoapods
- iOS Simulator or physical iOS device
Project Setup
Initial Setup
cd frontend/mobile-app
npm install
Platform Setup
Android Setup
# Add Android platform
ionic capacitor add android
# Generate app resources (icons, splash screens)
npm run resources
iOS Setup
# Add iOS platform
ionic capacitor add ios
# Generate app resources
npm run resources
# Copy web assets to iOS
ionic capacitor copy ios
# Update Capacitor
ionic capacitor update
# Install CocoaPods dependencies
cd ios/App
pod reintegrate
pod install
cd ../../
# Open in Xcode
ionic capacitor open ios
Development
Running on Device/Simulator
Android Development
# Local environment
npm run serve-local-android-device
# Development environment
npm run serve-develop-android-device
# Staging environment
npm run serve-staging-android-device
iOS Development
# Local environment
npm run serve-local-ios-device
# Development environment
npm run serve-develop-ios-device
# Staging environment
npm run serve-staging-ios-device
Live Reload
The -l
flag enables live reload, and --external
allows connections from external devices on the same network.
Building for Production
Android Builds
Development Build
npm run build-develop-android
Staging Build
npm run build-staging-android
Production Build
npm run build-production-android
iOS Builds
Local Build
npm run build-local-ios
Development Build
npm run build-develop-ios
Staging Build
npm run build-staging-ios
Production Build
npm run build-production-ios
Build Outputs
Android
- APK files: Located in
android/app/build/outputs/apk/
- AAB files: Located in
android/app/build/outputs/bundle/
(for Google Play Store)
iOS
- IPA files: Generated through Xcode after building
- Simulator builds: Available in Xcode's derived data
Environment Configuration
The app uses different environment configurations:
- Local:
IONIC_ENV=local
- Development server - Development:
IONIC_ENV=development
- Development API - UAT/Staging:
IONIC_ENV=uat
- Staging API - Production:
IONIC_ENV=production
- Production API
App Configuration
Capacitor Configuration
The main configuration is in capacitor.config.json
:
- App ID: co.uk.topspizza.mobile
- App Name: TopsPizza UK
- Web Directory: dist
- Splash Screen: Configured with custom settings
Ionic Configuration
Basic Ionic settings in ionic.config.json
:
- Project Type: Vue
- Integration: Capacitor
App Version Management
The mobile app version can be updated in two places:
1. Environment File
- Path:
frontend/env/.env.production
- During the build process, the version specified in this file is used to set the app version for both Android and iOS.
- The build scripts and
vue.config.js
read this value and update the native project files accordingly.
2. Nova Settings
- The app version can also be managed from the Nova admin panel under settings.
- This allows for dynamic version management and visibility for administrators.
Troubleshooting
Common Issues
Android Build Issues
- Gradle sync failed: Check Android SDK installation
- Missing dependencies: Run
npm install
and sync project - Permission issues: Ensure proper file permissions
iOS Build Issues
- CocoaPods errors: Run
pod install
inios/App
directory - Xcode build errors: Clean build folder and rebuild
- Signing issues: Check provisioning profiles and certificates
Debug Commands
# Check Capacitor status
ionic capacitor status
# Sync project
ionic capacitor sync
# Update Capacitor
ionic capacitor update
# Clean and rebuild
ionic capacitor clean
Deployment
Android Deployment
- Build the app using appropriate environment script
- Test APK/AAB on target devices
- Upload AAB to Google Play Console for release
iOS Deployment
- Build the app using appropriate environment script
- Archive in Xcode
- Upload to App Store Connect for review
Updating the APK/AAB on Google Play Store Console
- Build the Release APK/AAB
- Run the production build command:
bash npm run build-production-android
-
The output file will be in:
- APK:
frontend/mobile-app/android/app/build/outputs/apk/release/
- AAB:
frontend/mobile-app/android/app/build/outputs/bundle/release/
- APK:
-
Sign the APK/AAB
-
Ensure your APK/AAB is signed with your release key. (Capacitor/Android Studio usually handles this if configured.)
-
Login to Google Play Console
-
Go to Google Play Console.
-
Select Your App
-
Choose the app you want to update.
-
Create a New Release
- Go to Release > Production (or your desired track).
-
Click Create new release.
-
Upload the APK/AAB
-
Drag and drop or browse to upload your new APK or AAB file.
-
Fill in Release Details
-
Add release notes and any required information.
-
Review and Rollout
- Click Review release.
-
If all checks pass, click Start rollout to production (or your chosen track).
-
Wait for Review
- Google will review your release. Once approved, it will be available on the Play Store.
Resources
- Ionic Capacitor Documentation
- Ionic Framework Documentation
- Android Developer Guide
- iOS Developer Documentation