Skip to content

Checking your reading list…

Retry verification

Stay curious. Build better.

Appearance

Choose how BestHub looks on this device.

Changes apply immediately.

Search articles

Open Discover with these filters

Suggested searches

Flutter App Size Optimization Strategies for iOS

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.

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<dynamic, dynamic> to concrete types.

class PItemInfoInternal {
  static PItemInfoInternal fromJson(Map<dynamic, dynamic> 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.

About this article

For questions about attribution, corrections or content rights, please contactadmin@besthub.devand we will review it promptly.

DartFlutterMobile DevelopmentiOSApp Size

Discussion 0

Questions, practical examples and thoughtful responses.

Open full discussion