@@ -519,6 +519,82 @@ void main() {
519519 Xcode : () => xcode,
520520 });
521521
522+ testUsingContext ('updates Generated.xcconfig before and after launch' , () async {
523+ final Completer <void > debugStartedCompleter = Completer <void >();
524+ final Completer <void > debugEndedCompleter = Completer <void >();
525+ final IOSDevice iosDevice = setUpIOSDevice (
526+ fileSystem: fileSystem,
527+ processManager: FakeProcessManager .any (),
528+ logger: logger,
529+ artifacts: artifacts,
530+ isCoreDevice: true ,
531+ coreDeviceControl: FakeIOSCoreDeviceControl (),
532+ xcodeDebug: FakeXcodeDebug (
533+ expectedProject: XcodeDebugProject (
534+ scheme: 'Runner' ,
535+ xcodeWorkspace: fileSystem.directory ('/ios/Runner.xcworkspace' ),
536+ xcodeProject: fileSystem.directory ('/ios/Runner.xcodeproj' ),
537+ ),
538+ expectedDeviceId: '123' ,
539+ expectedLaunchArguments: < String > ['--enable-dart-profiling' ],
540+ debugStartedCompleter: debugStartedCompleter,
541+ debugEndedCompleter: debugEndedCompleter,
542+ ),
543+ );
544+
545+ setUpIOSProject (fileSystem);
546+ final FlutterProject flutterProject = FlutterProject .fromDirectory (fileSystem.currentDirectory);
547+ final BuildableIOSApp buildableIOSApp = BuildableIOSApp (flutterProject.ios, 'flutter' , 'My Super Awesome App.app' );
548+ fileSystem.directory ('build/ios/Release-iphoneos/My Super Awesome App.app' ).createSync (recursive: true );
549+
550+ final FakeDeviceLogReader deviceLogReader = FakeDeviceLogReader ();
551+
552+ iosDevice.portForwarder = const NoOpDevicePortForwarder ();
553+ iosDevice.setLogReader (buildableIOSApp, deviceLogReader);
554+
555+ // Start writing messages to the log reader.
556+ Timer .run (() {
557+ deviceLogReader.addLine ('Foo' );
558+ deviceLogReader.addLine ('The Dart VM service is listening on http://127.0.0.1:456' );
559+ });
560+
561+ final Future <LaunchResult > futureLaunchResult = iosDevice.startApp (
562+ buildableIOSApp,
563+ debuggingOptions: DebuggingOptions .enabled (const BuildInfo (
564+ BuildMode .debug,
565+ null ,
566+ buildName: '1.2.3' ,
567+ buildNumber: '4' ,
568+ treeShakeIcons: false ,
569+ )),
570+ platformArgs: < String , Object > {},
571+ );
572+
573+ await debugStartedCompleter.future;
574+
575+ // Validate CoreDevice build settings were used
576+ final File config = fileSystem.directory ('ios' ).childFile ('Flutter/Generated.xcconfig' );
577+ expect (config.existsSync (), isTrue);
578+
579+ String contents = config.readAsStringSync ();
580+ expect (contents, contains ('CONFIGURATION_BUILD_DIR=/build/ios/iphoneos' ));
581+
582+ debugEndedCompleter.complete ();
583+
584+ await futureLaunchResult;
585+
586+ // Validate CoreDevice build settings were removed after launch
587+ contents = config.readAsStringSync ();
588+ expect (contents.contains ('CONFIGURATION_BUILD_DIR' ), isFalse);
589+ }, overrides: < Type , Generator > {
590+ ProcessManager : () => FakeProcessManager .any (),
591+ FileSystem : () => fileSystem,
592+ Logger : () => logger,
593+ Platform : () => macPlatform,
594+ XcodeProjectInterpreter : () => fakeXcodeProjectInterpreter,
595+ Xcode : () => xcode,
596+ });
597+
522598 testUsingContext ('fails when Xcode project is not found' , () async {
523599 final IOSDevice iosDevice = setUpIOSDevice (
524600 fileSystem: fileSystem,
@@ -750,20 +826,25 @@ class FakeXcodeDebug extends Fake implements XcodeDebug {
750826 this .expectedProject,
751827 this .expectedDeviceId,
752828 this .expectedLaunchArguments,
829+ this .debugStartedCompleter,
830+ this .debugEndedCompleter,
753831 });
754832
755833 final bool debugSuccess;
756834
757835 final XcodeDebugProject ? expectedProject;
758836 final String ? expectedDeviceId;
759837 final List <String >? expectedLaunchArguments;
838+ final Completer <void >? debugStartedCompleter;
839+ final Completer <void >? debugEndedCompleter;
760840
761841 @override
762842 Future <bool > debugApp ({
763843 required XcodeDebugProject project,
764844 required String deviceId,
765845 required List <String > launchArguments,
766846 }) async {
847+ debugStartedCompleter? .complete ();
767848 if (expectedProject != null ) {
768849 expect (project.scheme, expectedProject! .scheme);
769850 expect (project.xcodeWorkspace.path, expectedProject! .xcodeWorkspace.path);
@@ -776,6 +857,7 @@ class FakeXcodeDebug extends Fake implements XcodeDebug {
776857 if (expectedLaunchArguments != null ) {
777858 expect (expectedLaunchArguments, launchArguments);
778859 }
860+ await debugEndedCompleter? .future;
779861 return debugSuccess;
780862 }
781863}
0 commit comments