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
| Flag | Purpose | Impact |
|---|---|---|
--release | Release mode compilation | Enables all optimizations |
--tree-shake-icons | Remove unused icons | ~2-5 MB size reduction |
--split-debug-info | Extract debug symbols | ~10-15 MB size reduction |
--obfuscate | Obfuscate code | Security + compression |
--dart-define-from-file | Environment variables | Production config |
Build Configuration Files
1. Environment Files
Create.env.production for production builds:
2. Export Options (iOS)
Createios/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 theMemoryProfiler utility in debug mode:
Expected Bundle Sizes
| Build Type | Size | Notes |
|---|---|---|
| Debug (unoptimized) | ~80-100 MB | Full debug symbols, no optimization |
| Release (unoptimized) | ~50-60 MB | Basic optimization only |
| Release (optimized) | ~20-30 MB | All optimizations enabled |
| App Store (device) | ~15-20 MB | With App Thinning |
Build Scripts
Automated Release Build
Createscripts/build_release.sh:
Size Analysis Script
Createscripts/analyze_size.sh:
App Thinning (iOS)
Apple automatically applies App Thinning for App Store distributions:- Slicing: Delivers only assets for specific device
- Bitcode: Allows Apple to recompile for new architectures
- On-Demand Resources: Downloads resources when needed
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
- Check asset sizes:
find assets -type f -exec ls -lh {} \; - Remove unused dependencies
- Compress images
- Use deferred loading for optional features
Slow Build Times
- Use
--analyze-sizeto identify bottlenecks - Clean build folder:
flutter clean - Update Flutter:
flutter upgrade - Use
--no-tree-shake-iconsduring development
Obfuscation Issues
- Check stack traces with mapping file
- Disable obfuscation for debugging: remove
--obfuscate - Keep symbols for crash reporting
Resources
Last Updated: 2025-11-15 Maintained By: Frontend Developer / DevOps Engineer