Skip to main content

Build Optimization Guide

Overview

This document provides instructions for building optimized release versions of the AI-Powered Photo Journaling app with maximum performance and minimal bundle size.

Release Build Commands

iOS Release Build (Optimized)

IPA Build for App Store

Build Flags Explained

Build Configuration Files

1. Environment Files

Create .env.production for production builds:

2. Export Options (iOS)

Create ios/ExportOptions.plist:

Size Optimization Steps

1. Pre-Build Optimization

2. Asset Optimization

3. Dependency Audit

4. Code Analysis

Performance Profiling

1. Profile Mode Build

2. DevTools Profiling

3. Memory Profiling

Use the MemoryProfiler utility in debug mode:

Expected Bundle Sizes

Build Scripts

Automated Release Build

Create scripts/build_release.sh:
Make it executable:

Size Analysis Script

Create scripts/analyze_size.sh:

App Thinning (iOS)

Apple automatically applies App Thinning for App Store distributions:
  1. Slicing: Delivers only assets for specific device
  2. Bitcode: Allows Apple to recompile for new architectures
  3. On-Demand Resources: Downloads resources when needed
Expected size reduction: 30-40%

Build Verification Checklist

Before submitting to App Store:
  • All tests passing (flutter test)
  • No analysis warnings (flutter analyze)
  • Performance profiled in profile mode
  • Memory leaks checked with MemoryProfiler
  • Image cache optimized
  • Bundle size < 30 MB (pre-thinning)
  • App launches in < 2 seconds
  • Timeline scrolls at 60 FPS
  • No crashes in TestFlight
  • All features working in release mode
  • Analytics/error tracking configured
  • Debug symbols uploaded

Continuous Integration

GitHub Actions Example

Troubleshooting

Build Too Large

  1. Check asset sizes: find assets -type f -exec ls -lh {} \;
  2. Remove unused dependencies
  3. Compress images
  4. Use deferred loading for optional features

Slow Build Times

  1. Use --analyze-size to identify bottlenecks
  2. Clean build folder: flutter clean
  3. Update Flutter: flutter upgrade
  4. Use --no-tree-shake-icons during development

Obfuscation Issues

  1. Check stack traces with mapping file
  2. Disable obfuscation for debugging: remove --obfuscate
  3. Keep symbols for crash reporting

Resources


Last Updated: 2025-11-15 Maintained By: Frontend Developer / DevOps Engineer