From 90b0b67618998ea2dfda751bcd09d74f7fd6572b Mon Sep 17 00:00:00 2001 From: "Dat H. Pham" Date: Fri, 22 May 2026 22:25:29 +0700 Subject: [PATCH] fix: work around Flutter 3.38.9 DART_DEFINES bug with version-length dependency Flutter 3.38.9's assemble.dart crashes ('Improperly formatted define flag') when the base64-encoded DART_DEFINES value contains no '=' padding character, which depends on the byte-length of the encoded string. For SENTRY_RELEASE=X.Y.Z this means any version where X.Y.Z is exactly 6 chars (e.g. 0.29.1, 0.30.0) crashes, while 0.28.19 (7 chars) happens to work. Append a constant '_FB_PAD=' define whose base64 always ends in '==' so the comma-joined DART_DEFINES is guaranteed to contain '=' regardless of version. --- ios/fastlane/Fastfile | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ios/fastlane/Fastfile b/ios/fastlane/Fastfile index d91be68cd..05984129e 100644 --- a/ios/fastlane/Fastfile +++ b/ios/fastlane/Fastfile @@ -52,16 +52,24 @@ platform :ios do ) # Pass the pubspec version (X.Y.Z, no -rc suffix) to the Dart layer as SENTRY_RELEASE. # Read from pubspec.yaml (same source as CI release.yaml) to guarantee consistency. - # Flutter 3.38.9+ (xcode_backend.dart) passes DART_DEFINES as-is to --DartDefines; - # plain KEY=VALUE format required — base64 encoding was removed in Flutter 3.38.9. + # + # DART_DEFINES must be a comma-separated list of base64-encoded "KEY=VALUE" entries + # (matches Flutter's encodeDartDefines in build_info.dart). Flutter 3.38.9 has a bug + # where assemble.dart:282 crashes if the base64 string has no '=' padding, which + # happens when "SENTRY_RELEASE=X.Y.Z" length is divisible by 3. We append a benign + # padding define ("_FB_PAD=") whose base64 always ends in '==' so the joined value + # is guaranteed to contain '=', avoiding the Flutter bug. + require 'base64' pubspec = File.read(File.expand_path("../../pubspec.yaml", __dir__)) sentry_release = pubspec.match(/^version:\s+(\S+)/)[1].split("+").first + sentry_define = Base64.strict_encode64("SENTRY_RELEASE=#{sentry_release}") + padding_define = Base64.strict_encode64("_FB_PAD=") # always encodes to "X0ZCX1BBRD0=" build_app( scheme: "Runner", configuration: "Release", workspace: "Runner.xcworkspace", export_method: "app-store", - xcargs: "DART_DEFINES=SENTRY_RELEASE=#{sentry_release}", + xcargs: "DART_DEFINES=#{sentry_define},#{padding_define}", ) upload_to_testflight( skip_waiting_for_build_processing: true,