Flutterアプリの難読化とエラーレポート(iOS)

4c6ec167a614173c5b31aaf4d1defa19?s=47 Hiroki Matsue
December 06, 2018

 Flutterアプリの難読化とエラーレポート(iOS)

"Flutter Meetup Tokyo #6"で使った資料です。
https://flutter-jp.connpass.com/event/105834/

4c6ec167a614173c5b31aaf4d1defa19?s=128

Hiroki Matsue

December 06, 2018
Tweet

Transcript

  1. FlutterΞϓϦͷ೉ಡԽͱ ΤϥʔϨϙʔτ(iOS) Hiroki Matsue Dec 6th, 2018 Flutter Meetup Tokyo

    #6
  2. Hiroki Matsue (@macs_6)

  3. FlutterͰIIJmio޲͚ʹ ʮΈ͓εΠονʯΛ ϦϦʔε

  4. None
  5. [࣭໰] FlutterͰΞϓϦΛ ϦϦʔε͍ͯ͠Δਓʁ

  6. [࣭໰] ϦϦʔεલʹ ೉ಡԽͨ͠ਓʁ

  7. ϦϦʔεؔ࿈ͷυΩϡϝϯτ https://flutter.io/docs/deployment/ios

  8. None
  9. None
  10. ࠷ॳʹॻ͍͚ͯ͋ͬͨͲ ݟམͱͯͨ͠ (AndroidͷProGuardରԠͯͯ͠ؾ͍ͮͨ)

  11. ͪͳΈʹ

  12. (ϦϦʔεؔ࿈Ͱ୤ઢ) ΞΠίϯ࡞੒͸"flutterlaunchericons"࢖͏ͱ 1ͭͷը૾͔Β͍͍ײ͡ʹ࡞ͬͯ͘ΕΔ

  13. iOS͸Dartίʔυ෦෼͕ ೉ಡԽͷର৅

  14. ΍Δ͜ͱ͸build࣌ʹ ΦϓγϣϯΛ͚ͭΔ͚ͩ (Կނ͔ॳظঢ়ଶͰ͸ରԠ͞Εͯͳ͍ ) https://github.com/flutter/flutter/wiki/Obfuscating-Dart-Code

  15. <ProjectRoot>/ios/Flutter/Release.xcconfig EXTRA_GEN_SNAPSHOT_OPTIONS=--obfuscate

  16. # <ProjectRoot>/packages/flutter_tools/bin/xcode_backend.sh 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 ... RunCommand "${FLUTTER_ROOT}/bin/flutter" --suppress-analytics \ ${verbose_flag} \ build aot \ --output-dir="${build_dir}/aot" \ --target-platform=ios \ --target="${target_path}" \ --${build_mode} \ --ios-arch="${archs}" \ ${local_engine_flag} \ ${track_widget_creation_flag} \ ${extra_gen_snapshot_options_or_none}
  17. # <ProjectRoot>/packages/flutter_tools/bin/xcode_backend.sh 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 ... RunCommand "${FLUTTER_ROOT}/bin/flutter" --suppress-analytics \ ${verbose_flag} \ build aot \ --output-dir="${build_dir}/aot" \ --target-platform=ios \ --target="${target_path}" \ --${build_mode} \ --ios-arch="${archs}" \ ${local_engine_flag} \ ${track_widget_creation_flag} \ ${extra_gen_snapshot_options_or_none}
  18. xcode_backend.sh ͱ͸ʁ Build PhaseͷRun ScriptͰ࢖ΘΕ͍ͯΔεΫϦϓτ Xcode͔Β΋Dartίʔυ͕build͞ΕΔͷ͸͜Εͷ͓͔͛

  19. (୤ઢ2) طଘΞϓϦʹFlutterΛಋೖ͢Δ࣌͸ xcode_backend.sh embed Add2AppϘʔυ্Ͱઈࢍ։ൃத

  20. ͜ΕͰϏϧυ͢Ε͹ ೉ಡԽ׬ྃʂ Χϯλϯʂ

  21. ೉ಡԽͷ֬ೝํ๏ʁ

  22. App.frameworkΛ֬ೝ͢Δ $ strings build/ios/Release-iphoneos/Runner.app/Frameworks/App.framework/App ... get:_vxa@7048458x get:_aLa@9040228x get:_DLa@7048458x ...

  23. ೉ಡԽͷલޙͰൺֱ before get:_count@7048458 get:_onData@9040228 get:_isSubscribed@7048458 after get:_vxa@7048458x get:_aLa@9040228x get:_DLa@7048458x

  24. Dartίʔυ͕೉ಡԽ͞Εͨ

  25. ...ϦϦʔεޙͷ͋Δ೔

  26. None
  27. SentryͷΤϥʔϨϙʔτ΋ ೉ಡԽ͞ΕͯΔ

  28. ೉ಡԽલͷΤϥʔϨϙʔτ

  29. ։ൃத͸ؾ͔ͮͳ͔ͬͨ

  30. ೉ಡԽͷલޙͰൺֱ before main.dart in SampleApp.build at line 48 after SEd

    in bZ.opa at line 48
  31. ࣗ෼΋ಡΊͳ͍

  32. ϦϦʔεࡁΞϓϦͷ Τϥʔ΋ݟ͍ͨ

  33. mapϑΝΠϧΛग़ྗ͢Δ ઌ΄ͲͷυΩϡϝϯτʹ͋ͬͨઃఆ EXTRA_GEN_SNAPSHOT_OPTIONS=--obfuscate mapϑΝΠϧΛग़ྗ͢ΔઃఆΛ௥Ճ EXTRA_GEN_SNAPSHOT_OPTIONS=--obfuscate, ɹ --save-obfuscation-map=ios_dart_symbols_${FLUTTER_BUILD_NUMBER}.json

  34. ग़ྗ͞ΕͨmapϑΝΠϧ $ cat ios_dart_symbols_5.json ... "_BuildJsonListener","_Gf", "CustomSymbolRenderer","cs", "devicePixelRatio","saa" ... ͜ΕΛࢀর͢Ε͹ಡΊΔ

    !
  35. աڈʹϦϦʔεͨ͠ΞϓϦͷmapϑΝΠϧʁ ࢼͨ͠ͱ͜Ζɺ ੜ੒ݩͷίʔυ͕ಉ͡Ͱ͋Ε͹map΋ಉ͡ʹͳͬͨ

  36. ·ͱΊ

  37. ·ͱΊ • FlutterͩͱiOSͰ΋Dartίʔυͷ೉ಡԽ࡞ۀ͕͋Δ • stringsίϚϯυͰνΣοΫ͢Δͷָ͕ • mapϑΝΠϧ΋ग़ྗ͓ͯ͘͠ͱSentryղಡʹ࢖͑Δ # before main.dart

    in SampleApp.build at line 48 # after SEd in bZ.opa at line 48
  38. Έ͓εΠονɺੋඇ͝ར༻͍ͩ͘͞

  39. Thanks