iosflutterdartobfuscation

Who to obfuscating flutter IOS app using extra_gen_snapshot_options?


I'm reading Flutter official instructions for Obfuscating Dart Code and I want to obfuscate my app for IOS.

The instruction says that I need to place the extra_gen_snapshot_options_or_none flag in the <FlutterRoot>/packages/flutter_tools/bin/xcode_backend.sh file. (IOS step1)

Where should I place it? Is it a necessary step?


Solution

  • Go to the BuildApp() function inside the <FlutterRoot>/packages/flutter_tools/bin/xcode_backend.sh file.

    Then place the flag as described in the instructions.

    That's how to it should be:

    BuildApp() {
      local extra_gen_snapshot_options_or_none=""
      if [[ -n "$EXTRA_GEN_SNAPSHOT_OPTIONS" ]]; then
        extra_gen_snapshot_options_or_none="--extra-gen-snapshot-options=$EXTRA_GEN_SNAPSHOT_OPTIONS"
      fi
    
      local project_path="${SOURCE_ROOT}/.."
      if [[ -n "$FLUTTER_APPLICATION_PATH" ]]; then
        project_path="${FLUTTER_APPLICATION_PATH}"
      fi
    
      local target_path="lib/main.dart"
      if [[ -n "$FLUTTER_TARGET" ]]; then
        target_path="${FLUTTER_TARGET}"
      fi
    
      local derived_dir="${SOURCE_ROOT}/Flutter"
      if [[ -e "${project_path}/.ios" ]]; then
        derived_dir="${project_path}/.ios/Flutter"
      fi
    }