Revert "Skip injecting Bonjour settings when port publication is disabled (#136562)"

This reverts commit 0383d8ba9eb16ffd801311742dd40dd985d68fc1.
diff --git a/dev/devicelab/lib/tasks/perf_tests.dart b/dev/devicelab/lib/tasks/perf_tests.dart
index aca0742..48bf20d 100644
--- a/dev/devicelab/lib/tasks/perf_tests.dart
+++ b/dev/devicelab/lib/tasks/perf_tests.dart
@@ -886,7 +886,6 @@
              '-v',
             '--profile',
             '--target=$target',
-            '--no-publish-port',
           ]);
           final String buildRoot = path.join(testDirectory, 'build');
           applicationBinaryPath = _findDarwinAppInBuildDirectory(buildRoot);
diff --git a/packages/flutter_tools/bin/xcode_backend.dart b/packages/flutter_tools/bin/xcode_backend.dart
index 70e8564..6e3fb71 100644
--- a/packages/flutter_tools/bin/xcode_backend.dart
+++ b/packages/flutter_tools/bin/xcode_backend.dart
@@ -256,12 +256,6 @@
 
   // Add the vmService publisher Bonjour service to the produced app bundle Info.plist.
   void addVmServiceBonjourService() {
-    // Skip adding Bonjour service settings when DISABLE_PORT_PUBLICATION is YES.
-    // These settings are not needed if port publication is disabled.
-    if (environment['DISABLE_PORT_PUBLICATION'] == 'YES') {
-      return;
-    }
-
     final String buildMode = parseFlutterBuildMode();
 
     // Debug and profile only.
diff --git a/packages/flutter_tools/lib/src/commands/build_ios.dart b/packages/flutter_tools/lib/src/commands/build_ios.dart
index 8dab363..117414e 100644
--- a/packages/flutter_tools/lib/src/commands/build_ios.dart
+++ b/packages/flutter_tools/lib/src/commands/build_ios.dart
@@ -27,11 +27,7 @@
 /// Builds an .app for an iOS app to be used for local testing on an iOS device
 /// or simulator. Can only be run on a macOS host.
 class BuildIOSCommand extends _BuildIOSSubCommand {
-  BuildIOSCommand({
-    required super.logger,
-    required bool verboseHelp,
-  }) : super(verboseHelp: verboseHelp) {
-    addPublishPort(verboseHelp: verboseHelp);
+  BuildIOSCommand({ required super.logger, required super.verboseHelp }) {
     argParser
       ..addFlag('config-only',
         help: 'Update the project configuration without performing a build. '
@@ -662,7 +658,6 @@
       configOnly: configOnly,
       buildAction: xcodeBuildAction,
       deviceID: globals.deviceManager?.specifiedDeviceId,
-      disablePortPublication: usingCISystem && await disablePortPublication,
     );
     xcodeBuildResult = result;
 
diff --git a/packages/flutter_tools/lib/src/ios/devices.dart b/packages/flutter_tools/lib/src/ios/devices.dart
index 56cfa87..d07542d 100644
--- a/packages/flutter_tools/lib/src/ios/devices.dart
+++ b/packages/flutter_tools/lib/src/ios/devices.dart
@@ -501,7 +501,6 @@
           targetOverride: mainPath,
           activeArch: cpuArchitecture,
           deviceID: id,
-          disablePortPublication: debuggingOptions.usingCISystem && debuggingOptions.disablePortPublication,
       );
       if (!buildResult.success) {
         _logger.printError('Could not build the precompiled application for the device.');
diff --git a/packages/flutter_tools/lib/src/ios/mac.dart b/packages/flutter_tools/lib/src/ios/mac.dart
index 6865b36..8819b5c 100644
--- a/packages/flutter_tools/lib/src/ios/mac.dart
+++ b/packages/flutter_tools/lib/src/ios/mac.dart
@@ -135,7 +135,6 @@
   String? deviceID,
   bool configOnly = false,
   XcodeBuildAction buildAction = XcodeBuildAction.build,
-  bool disablePortPublication = false,
 }) async {
   if (!upgradePbxProjWithFlutterAssets(app.project, globals.logger)) {
     return XcodeBuildResult(success: false);
@@ -383,12 +382,6 @@
       _kResultBundleVersion,
     ]);
 
-    // Adds a setting which xcode_backend.dart will use to skip adding Bonjour
-    // service settings to the Info.plist.
-    if (disablePortPublication) {
-      buildCommands.add('DISABLE_PORT_PUBLICATION=YES');
-    }
-
     // Don't log analytics for downstream Flutter commands.
     // e.g. `flutter build bundle`.
     buildCommands.add('FLUTTER_SUPPRESS_ANALYTICS=true');
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/build_ios_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/build_ios_test.dart
index 88f4212..8f0ae0d 100644
--- a/packages/flutter_tools/test/commands.shard/hermetic/build_ios_test.dart
+++ b/packages/flutter_tools/test/commands.shard/hermetic/build_ios_test.dart
@@ -134,7 +134,6 @@
     bool verbose = false,
     bool simulator = false,
     bool customNaming = false,
-    bool disablePortPublication = false,
     String? deviceId,
     int exitCode = 0,
     String? stdout,
@@ -178,8 +177,6 @@
         ],
         '-resultBundlePath', _xcBundleDirectoryPath,
         '-resultBundleVersion', '3',
-        if (disablePortPublication)
-          'DISABLE_PORT_PUBLICATION=YES',
         'FLUTTER_SUPPRESS_ANALYTICS=true',
         'COMPILER_INDEX_STORE_ENABLE=NO',
       ],
@@ -284,65 +281,6 @@
     XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
   });
 
-  testUsingContext('ios build invokes xcode build with disable port publication setting', () async {
-    final BuildCommand command = BuildCommand(
-      androidSdk: FakeAndroidSdk(),
-      buildSystem: TestBuildSystem.all(BuildResult(success: true)),
-      fileSystem: MemoryFileSystem.test(),
-      logger: BufferLogger.test(),
-      osUtils: FakeOperatingSystemUtils(),
-    );
-    createMinimalMockProjectFiles();
-
-    await createTestCommandRunner(command).run(
-      const <String>['build', 'ios', '--no-pub', '--no-publish-port', '--ci']
-    );
-    expect(testLogger.statusText, contains('build/ios/iphoneos/Runner.app'));
-  }, overrides: <Type, Generator>{
-    FileSystem: () => fileSystem,
-    ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
-      xattrCommand,
-      setUpFakeXcodeBuildHandler(
-        disablePortPublication: true,
-        onRun: () {
-          fileSystem.directory('build/ios/Release-iphoneos/Runner.app').createSync(recursive: true);
-        },
-      ),
-      setUpRsyncCommand(),
-    ]),
-    Platform: () => macosPlatform,
-    XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
-  });
-
-  testUsingContext('ios build invokes xcode build without disable port publication setting when not in CI', () async {
-    final BuildCommand command = BuildCommand(
-      androidSdk: FakeAndroidSdk(),
-      buildSystem: TestBuildSystem.all(BuildResult(success: true)),
-      fileSystem: MemoryFileSystem.test(),
-      logger: BufferLogger.test(),
-      osUtils: FakeOperatingSystemUtils(),
-    );
-    createMinimalMockProjectFiles();
-
-    await createTestCommandRunner(command).run(
-      const <String>['build', 'ios', '--no-pub', '--no-publish-port']
-    );
-    expect(testLogger.statusText, contains('build/ios/iphoneos/Runner.app'));
-  }, overrides: <Type, Generator>{
-    FileSystem: () => fileSystem,
-    ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
-      xattrCommand,
-      setUpFakeXcodeBuildHandler(
-        onRun: () {
-          fileSystem.directory('build/ios/Release-iphoneos/Runner.app').createSync(recursive: true);
-        },
-      ),
-      setUpRsyncCommand(),
-    ]),
-    Platform: () => macosPlatform,
-    XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
-  });
-
   testUsingContext('ios build invokes xcode build with renamed xcodeproj and xcworkspace', () async {
     final BuildCommand command = BuildCommand(
       androidSdk: FakeAndroidSdk(),
diff --git a/packages/flutter_tools/test/integration.shard/xcode_backend_test.dart b/packages/flutter_tools/test/integration.shard/xcode_backend_test.dart
index 01d3be8..d34d242 100644
--- a/packages/flutter_tools/test/integration.shard/xcode_backend_test.dart
+++ b/packages/flutter_tools/test/integration.shard/xcode_backend_test.dart
@@ -183,30 +183,5 @@
 ''');
       expect(result, const ProcessResultMatcher());
     });
-
-    test('does not add bonjour settings when port publication is disabled', () async {
-      infoPlist.writeAsStringSync('''
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-</dict>
-</plist>''');
-
-      final ProcessResult result = await Process.run(
-        xcodeBackendPath,
-        <String>['test_vm_service_bonjour_service'],
-        environment: <String, String>{
-          'CONFIGURATION': 'Debug',
-          'BUILT_PRODUCTS_DIR': buildDirectory.path,
-          'INFOPLIST_PATH': 'Info.plist',
-          'DISABLE_PORT_PUBLICATION': 'YES',
-        },
-      );
-
-      expect(infoPlist.readAsStringSync().contains('NSBonjourServices'), isFalse);
-      expect(infoPlist.readAsStringSync().contains('NSLocalNetworkUsageDescription'), isFalse);
-      expect(result, const ProcessResultMatcher());
-    });
   }, skip: !io.Platform.isMacOS); // [intended] requires macos toolchain.
 }