Mobile Development 9 min read

Flutter App Size Optimization Strategies for iOS

The Xianyu team tackled iOS Flutter app bloat by analyzing App.framework, cutting excessive type‑casting, applying dwarf‑stack‑trace and obfuscation flags, stripping dSYM symbols, and removing duplicate assets, which together shrank the generated framework by over 30 % and improved download efficiency.

Xianyu Technology
Xianyu Technology
Xianyu Technology
Flutter App Size Optimization Strategies for iOS

The Xianyu technical team introduced Flutter in early 2018 for client development. After several feature migrations, the installation package size grew dramatically, increasing download time and data usage. Controlling the size of Flutter artifacts, especially the App.framework, became urgent.

iOS projects depend on the following Flutter components:

Flutter.framework : Flutter engine and core library

App.framework : Dart business source files

Flutter Plugin : Compiled plugin frameworks

flutter_assets : Static resources such as fonts and images

Initial migration of the detail page added ~20 MB to the IPA, and the subsequent publish page added another ~4 MB. Analysis showed that Flutter.framework remains ~20 MB, while App.framework grew by ~10 MB after adding new business logic.

Since the size of Flutter.framework is hard to shrink, the focus is on reducing the size of App.framework.

Flutter artifact size analysis

Run the following command to build a release‑mode App.framework and print its size:

flutter build aot --release --extra-gen-snapshot-options=--print-snapshot-sizes

The output (excerpt) is:

Building AOT snapshot in release mode (android-arm-release)...
VMIsolate (CodeSize): 4660
Isolate (CodeSize): 2585632
ReadOnlyData (CodeSize): 2693576
Instructions (CodeSize): 8064816
Total (CodeSize): 13348684
Built to build/aot/.

Explanation of the categories:

Instructions – size of the generated binary code

ReadOnlyData – metadata and string data

VMIsolate/Isolate – size of remaining objects (constants, VM metadata, etc.)

To pinpoint the size contribution of each business module, the team runs:

flutter --suppress-analytics build aot --output-dir=build/aot --target-platform=ios --target=lib/main.dart --release --ios-arch=arm64 --extra-gen-snapshot-options="--dwarf_stack_traces,--print-snapshot-sizes,--print_instructions_sizes_to=build/aot.json"

Then the generated aot.json is visualized with a Dart tool:

dart ./bin/run_binary_size_analysis.dart build/aot.json path_to_webpage_dir

The visual report highlights large symbols and files. For example, the method PItemInfoInternal.fromJson occupies a lot of space because it performs extensive type‑casting from Map to concrete types.

class PItemInfoInternal {
  static PItemInfoInternal fromJson(Map
map) {
    String id = map['id'] as String;
    String attributes = map['attributes'] as String;
    String title = map['title'] as String;
    // ...
  }
}

Such casts generate additional type‑checking and exception handling code, inflating the binary.

Optimization measures

Reduce explicit type‑casting (e.g., as String , as Bool , as Int ) and extract shared logic into static methods, saving >400 KB.

Use compiler flags to shrink code: --dwarf_stack_traces (omit stack‑trace symbols, ~6.2 % reduction) --obfuscate (shorten identifiers, ~2.5 % reduction) Combined flags: flutter build aot --release --extra-gen-snapshot-options="--dwarf_stack_traces,--print-snapshot-sizes,--obfuscate"

Strip dSYM symbols from the iOS framework to cut ~20 % of App.framework size: RunCommand xcrun dsymutil -o "${build_dir}/aot/App.dSYM" "${app_framework}/App" RunCommand xcrun strip -x -S "${derived_dir}/App.framework/App"

Avoid duplicate resources by letting Flutter request native assets via BasicMessageChannel , eliminating redundant copies.

Result

Applying the above techniques reduced the size of the Flutter‑generated App.framework by more than 30 %. The team plans to explore lazy‑loading, further code‑generation analysis, and collaborate with Google for additional optimizations.

DartFluttermobile developmentOptimizationiOSAOTapp-size
Xianyu Technology
Written by

Xianyu Technology

Official account of the Xianyu technology team

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.