Git Flow + Build Flavors Implementation Guide

Overview

This document explains the new Git Flow + Build Flavors approach implemented for the Wellbeing Mapper app. This system separates production releases from beta testing builds using build-time configuration instead of runtime mode switching.

Key Benefits

Clean Production Releases: Production builds only include Private and Research modes
Comprehensive Beta Testing: Beta builds include all modes including App Testing
Side-by-side Installation: Different bundle identifiers allow both versions on same device
App Store Ready: Production builds are clean and ready for store submission
Developer Friendly: Easy switching between flavors during development

Branch Strategy (Git Flow)

Branch Structure

Workflow

  1. Develop features in feature/* branches
  2. Merge features to develop for integration testing
  3. Create beta releases from develop branch
  4. Merge stable develop to main for production releases
  5. Use hotfix/* branches for urgent production fixes

Build Flavors

Production Flavor

./build-flavors.sh production android
./build-flavors.sh production ios

Configuration:

Beta Flavor

./build-flavors.sh beta android
./build-flavors.sh beta ios

Configuration:

File Structure Changes

Android Configuration

android/app/build.gradle
├── flavorDimensions "default"
├── productFlavors {
│   ├── production { ... }
│   └── beta { ... }
└── }

iOS Configuration

ios/Runner/
├── Info-Production.plist  (Production configuration)
├── Info-Beta.plist        (Beta configuration)
└── Info.plist            (Active configuration, copied during build)

Flutter Code

lib/services/app_mode_service.dart
├── appFlavor detection via String.fromEnvironment('APP_FLAVOR')
├── getAvailableModes() → Returns modes based on build flavor
└── Build-time mode validation

Usage Instructions

1. Building Different Flavors

Build Production APK:

cd gauteng-wellbeing-mapper-app
./build-flavors.sh production android

Build Beta iOS:

cd gauteng-wellbeing-mapper-app
./build-flavors.sh beta ios

Build All Platforms:

cd gauteng-wellbeing-mapper-app
./build-flavors.sh production all
./build-flavors.sh beta all

2. Development Testing

Run in Production Mode:

flutter run --dart-define=APP_FLAVOR=production

Run in Beta Mode:

flutter run --dart-define=APP_FLAVOR=beta

3. Release Process

Beta Release Process:

  1. Ensure develop branch is stable
  2. Merge develop to beta branch
  3. Build beta flavor: ./build-flavors.sh beta all
  4. Distribute beta build to testers
  5. Collect feedback and fix issues in develop

Production Release Process:

  1. Ensure beta testing is complete
  2. Merge develop to main branch
  3. Build production flavor: ./build-flavors.sh production all
  4. Submit to App Store / Play Store
  5. Tag release: git tag v1.x.x

App Mode Behavior

Production Builds (APP_FLAVOR=production)

Beta Builds (APP_FLAVOR=beta)

Code Implementation Details

AppModeService Changes

// Build flavor detection
static const String appFlavor = String.fromEnvironment('APP_FLAVOR', defaultValue: 'production');

// Flavor-based mode availability
static List<AppMode> getAvailableModes() {
  if (isBetaBuild) {
    return [AppMode.private, AppMode.research, AppMode.appTesting];
  } else {
    return [AppMode.private, AppMode.research];
  }
}

Validation

Deployment Strategy

App Store Submission

  1. Use production flavor builds only
  2. Ensure main branch is used for production builds
  3. Test production build thoroughly before submission
  4. Production builds will not show App Testing mode

Beta Testing Distribution

  1. Use beta flavor builds for all testing
  2. Beta builds can be distributed via TestFlight, Firebase App Distribution, etc.
  3. Beta and production apps can coexist on same device
  4. Beta builds include full testing capabilities

Troubleshooting

Common Issues

Wrong mode available in build:

iOS build using wrong Info.plist:

Android build wrong app name/ID:

Debug Commands

Check current flavor in app:

print('Current app flavor: ${AppModeService.appFlavor}');
print('Is beta build: ${AppModeService.isBetaBuild}');
print('Available modes: ${AppModeService.getAvailableModes()}');

Verify build configuration:

# Check Android APK name
ls build/app/outputs/flutter-apk/

# Check Android bundle name  
ls build/app/outputs/bundle/

# Check current iOS Info.plist
cat ios/Runner/Info.plist | grep -A 1 CFBundleDisplayName

Migration Notes

From Previous System

Benefits of New System

  1. Cleaner production releases without testing features
  2. Proper beta testing with full feature sets
  3. App Store compliance with clear production builds
  4. Side-by-side testing of production and beta versions
  5. Automated flavor validation prevents incorrect mode access

Future Enhancements

Planned Improvements

Development Workflow Integration


Last Updated: January 2025
Version: 1.0
Author: GitHub Copilot (Implementation Guide)