@@ -42,7 +42,7 @@ import 'xcodeproj.dart';
4242const String kJITCrashFailureMessage =
4343 'Crash occurred when compiling unknown function in unoptimized JIT mode in unknown pass' ;
4444
45- const String kJITCrashFailureMessageInstructions = '''
45+ const String kJITCrashFailureInstructions = '''
4646════════════════════════════════════════════════════════════════════════════════
4747An upcoming change to iOS has caused a temporary break in Flutter's
4848debug mode on physical devices running iOS 18.4 (currently in beta).
@@ -762,7 +762,7 @@ class IOSDevice extends Device {
762762 });
763763 }
764764
765- final StreamSubscription <String > errorListener = _interceptErrorsFromLogs (
765+ final StreamSubscription <String >? errorListener = _interceptErrorsFromLogs (
766766 package,
767767 debuggingOptions: debuggingOptions,
768768 );
@@ -795,16 +795,22 @@ class IOSDevice extends Device {
795795 }
796796 }
797797 maxWaitForCI? .cancel ();
798- await errorListener.cancel ();
798+ await errorListener? .cancel ();
799799 return localUri;
800800 }
801801
802- /// Listen for specific errors and perform actions, such as printing guided
803- /// messages or exiting the tool.
804- StreamSubscription <String > _interceptErrorsFromLogs (
802+ /// Listen to device logs for crash on iOS 18.4+ due to JIT restriction. If
803+ /// found, give guided error and throw tool exit. Returns null and does not
804+ /// listen if device is less than iOS 18.4.
805+ StreamSubscription <String >? _interceptErrorsFromLogs (
805806 IOSApp ? package, {
806807 required DebuggingOptions debuggingOptions,
807808 }) {
809+ // Currently only checking for kJITCrashFailureMessage, which only should
810+ // be checked on iOS 18.4+.
811+ if (sdkVersion == null || sdkVersion! < Version (18 , 4 , null )) {
812+ return null ;
813+ }
808814 final DeviceLogReader deviceLogReader = getLogReader (
809815 app: package,
810816 usingCISystem: debuggingOptions.usingCISystem,
@@ -813,10 +819,8 @@ class IOSDevice extends Device {
813819 final Stream <String > logStream = deviceLogReader.logLines;
814820
815821 final StreamSubscription <String > errorListener = logStream.listen ((String line) {
816- if (sdkVersion != null && sdkVersion! >= Version (18 , 4 , null )) {
817- if (line.contains (kJITCrashFailureMessage)) {
818- throwToolExit (kJITCrashFailureMessageInstructions);
819- }
822+ if (line.contains (kJITCrashFailureMessage)) {
823+ throwToolExit (kJITCrashFailureInstructions);
820824 }
821825 });
822826
0 commit comments