Skip to content

Document the new workflow for Dart code obfuscation on Flutter #3827

@jonahwilliams

Description

@jonahwilliams

( See also #1567 )

As of Flutter v1.15.18 the information in https://github.com/flutter/flutter/wiki/Obfuscating-Dart-Code is out of date. We've stabilized the feature and made source code obfuscation stable, and it is supported by iOS and Android builds with the --obfuscate and --split-debug-info options.

The existing documentation for these features:


    --split-debug-info=</project-name/v1.2.3/>    In a release build, this flag reduces application size by storing Dart program
                                                  symbols in a separate file on the host rather than in the application. The value
                                                  of the flag should be a directory where program symbol files can be stored for
                                                  later use. These symbol files contain the information needed to symbolize Dart
                                                  stack traces. For an app built with this flag, the 'flutter symbolize' command
                                                  with the right program symbol file is required to obtain a human readable stack
                                                  trace.

    --[no-]obfuscate                              In a release build, this flag removes identifiers and replaces them with
                                                  randomized values for the purposes of source code obfuscation. This flag must
                                                  always be combined with "--split-debug-info" option, the mapping between the
                                                  values and the original identifiers is stored in the symbol map created in the
                                                  specified directory. For an app built with this flag, the 'flutter symbolize'
                                                  command with the right program symbol file is required to obtain a human readable
                                                  stack trace.
                                                  
                                                  Because all identifiers are renamed, methods like Object.runtimeType,
                                                  Type.toString, Enum.toString, Stacktrace.toString, Symbol.toString (for constant
                                                  symbols or those generated by runtime system) will return obfuscated results. Any
                                                  code or tests that rely on exact names will break.

These two flags must be combined in order to use obfuscation. split-debug-info should be a directory where flutter can output debug files.

We also need to document the functionality of --split-debug-info separately, since this can also reduce code size fairly dramatically.

Metadata

Metadata

Assignees

Labels

e2-daysEffort: < 5 daysp1-highMajor but not urgent concern: Resolve in months. Update each month.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions