Skip to content

Commit 54c0a35

Browse files
Reverts "Skip injecting Bonjour settings when port publication is disabled" (#136750)
Reverts flutter/flutter#136562 Initiated by: vashworth This change reverts the following previous change: Original Description: Some of our tests in CI are triggering the `NSLocalNetworkUsageDescription` dialog when they're not supposed to (flutter/flutter#129836) since it's disabled via flags (`--no-publish-port` for flutter/flutter and `--disable-vm-service-publication` for flutter/engine). Normally, we inject `NSLocalNetworkUsageDescription` (and other bonjour settings) to the Info.plist during the project build for debug and profile mode since by default they will publish the VM Service port over mDNS. To help diagnose the issue, though, this PR changes it so that we don't inject `NSLocalNetworkUsageDescription` (and other bonjour settings) when port publication is disabled since it shouldn't be needed. Hopefully, this will give us better error messages or cause the app to crash and end the test early (rather than timeout after 30 minutes).
1 parent 0cc2eff commit 54c0a35

File tree

7 files changed

+1
-108
lines changed

7 files changed

+1
-108
lines changed

dev/devicelab/lib/tasks/perf_tests.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,6 @@ class StartupTest {
886886
'-v',
887887
'--profile',
888888
'--target=$target',
889-
'--no-publish-port',
890889
]);
891890
final String buildRoot = path.join(testDirectory, 'build');
892891
applicationBinaryPath = _findDarwinAppInBuildDirectory(buildRoot);

packages/flutter_tools/bin/xcode_backend.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,6 @@ class Context {
256256

257257
// Add the vmService publisher Bonjour service to the produced app bundle Info.plist.
258258
void addVmServiceBonjourService() {
259-
// Skip adding Bonjour service settings when DISABLE_PORT_PUBLICATION is YES.
260-
// These settings are not needed if port publication is disabled.
261-
if (environment['DISABLE_PORT_PUBLICATION'] == 'YES') {
262-
return;
263-
}
264-
265259
final String buildMode = parseFlutterBuildMode();
266260

267261
// Debug and profile only.

packages/flutter_tools/lib/src/commands/build_ios.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@ import 'build.dart';
2727
/// Builds an .app for an iOS app to be used for local testing on an iOS device
2828
/// or simulator. Can only be run on a macOS host.
2929
class BuildIOSCommand extends _BuildIOSSubCommand {
30-
BuildIOSCommand({
31-
required super.logger,
32-
required bool verboseHelp,
33-
}) : super(verboseHelp: verboseHelp) {
34-
addPublishPort(verboseHelp: verboseHelp);
30+
BuildIOSCommand({ required super.logger, required super.verboseHelp }) {
3531
argParser
3632
..addFlag('config-only',
3733
help: 'Update the project configuration without performing a build. '
@@ -662,7 +658,6 @@ abstract class _BuildIOSSubCommand extends BuildSubCommand {
662658
configOnly: configOnly,
663659
buildAction: xcodeBuildAction,
664660
deviceID: globals.deviceManager?.specifiedDeviceId,
665-
disablePortPublication: usingCISystem && await disablePortPublication,
666661
);
667662
xcodeBuildResult = result;
668663

packages/flutter_tools/lib/src/ios/devices.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,6 @@ class IOSDevice extends Device {
501501
targetOverride: mainPath,
502502
activeArch: cpuArchitecture,
503503
deviceID: id,
504-
disablePortPublication: debuggingOptions.usingCISystem && debuggingOptions.disablePortPublication,
505504
);
506505
if (!buildResult.success) {
507506
_logger.printError('Could not build the precompiled application for the device.');

packages/flutter_tools/lib/src/ios/mac.dart

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ Future<XcodeBuildResult> buildXcodeProject({
135135
String? deviceID,
136136
bool configOnly = false,
137137
XcodeBuildAction buildAction = XcodeBuildAction.build,
138-
bool disablePortPublication = false,
139138
}) async {
140139
if (!upgradePbxProjWithFlutterAssets(app.project, globals.logger)) {
141140
return XcodeBuildResult(success: false);
@@ -383,12 +382,6 @@ Future<XcodeBuildResult> buildXcodeProject({
383382
_kResultBundleVersion,
384383
]);
385384

386-
// Adds a setting which xcode_backend.dart will use to skip adding Bonjour
387-
// service settings to the Info.plist.
388-
if (disablePortPublication) {
389-
buildCommands.add('DISABLE_PORT_PUBLICATION=YES');
390-
}
391-
392385
// Don't log analytics for downstream Flutter commands.
393386
// e.g. `flutter build bundle`.
394387
buildCommands.add('FLUTTER_SUPPRESS_ANALYTICS=true');

packages/flutter_tools/test/commands.shard/hermetic/build_ios_test.dart

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ void main() {
134134
bool verbose = false,
135135
bool simulator = false,
136136
bool customNaming = false,
137-
bool disablePortPublication = false,
138137
String? deviceId,
139138
int exitCode = 0,
140139
String? stdout,
@@ -178,8 +177,6 @@ void main() {
178177
],
179178
'-resultBundlePath', _xcBundleDirectoryPath,
180179
'-resultBundleVersion', '3',
181-
if (disablePortPublication)
182-
'DISABLE_PORT_PUBLICATION=YES',
183180
'FLUTTER_SUPPRESS_ANALYTICS=true',
184181
'COMPILER_INDEX_STORE_ENABLE=NO',
185182
],
@@ -284,65 +281,6 @@ void main() {
284281
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
285282
});
286283

287-
testUsingContext('ios build invokes xcode build with disable port publication setting', () async {
288-
final BuildCommand command = BuildCommand(
289-
androidSdk: FakeAndroidSdk(),
290-
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
291-
fileSystem: MemoryFileSystem.test(),
292-
logger: BufferLogger.test(),
293-
osUtils: FakeOperatingSystemUtils(),
294-
);
295-
createMinimalMockProjectFiles();
296-
297-
await createTestCommandRunner(command).run(
298-
const <String>['build', 'ios', '--no-pub', '--no-publish-port', '--ci']
299-
);
300-
expect(testLogger.statusText, contains('build/ios/iphoneos/Runner.app'));
301-
}, overrides: <Type, Generator>{
302-
FileSystem: () => fileSystem,
303-
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
304-
xattrCommand,
305-
setUpFakeXcodeBuildHandler(
306-
disablePortPublication: true,
307-
onRun: () {
308-
fileSystem.directory('build/ios/Release-iphoneos/Runner.app').createSync(recursive: true);
309-
},
310-
),
311-
setUpRsyncCommand(),
312-
]),
313-
Platform: () => macosPlatform,
314-
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
315-
});
316-
317-
testUsingContext('ios build invokes xcode build without disable port publication setting when not in CI', () async {
318-
final BuildCommand command = BuildCommand(
319-
androidSdk: FakeAndroidSdk(),
320-
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
321-
fileSystem: MemoryFileSystem.test(),
322-
logger: BufferLogger.test(),
323-
osUtils: FakeOperatingSystemUtils(),
324-
);
325-
createMinimalMockProjectFiles();
326-
327-
await createTestCommandRunner(command).run(
328-
const <String>['build', 'ios', '--no-pub', '--no-publish-port']
329-
);
330-
expect(testLogger.statusText, contains('build/ios/iphoneos/Runner.app'));
331-
}, overrides: <Type, Generator>{
332-
FileSystem: () => fileSystem,
333-
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
334-
xattrCommand,
335-
setUpFakeXcodeBuildHandler(
336-
onRun: () {
337-
fileSystem.directory('build/ios/Release-iphoneos/Runner.app').createSync(recursive: true);
338-
},
339-
),
340-
setUpRsyncCommand(),
341-
]),
342-
Platform: () => macosPlatform,
343-
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
344-
});
345-
346284
testUsingContext('ios build invokes xcode build with renamed xcodeproj and xcworkspace', () async {
347285
final BuildCommand command = BuildCommand(
348286
androidSdk: FakeAndroidSdk(),

packages/flutter_tools/test/integration.shard/xcode_backend_test.dart

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -183,30 +183,5 @@ void main() {
183183
''');
184184
expect(result, const ProcessResultMatcher());
185185
});
186-
187-
test('does not add bonjour settings when port publication is disabled', () async {
188-
infoPlist.writeAsStringSync('''
189-
<?xml version="1.0" encoding="UTF-8"?>
190-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
191-
<plist version="1.0">
192-
<dict>
193-
</dict>
194-
</plist>''');
195-
196-
final ProcessResult result = await Process.run(
197-
xcodeBackendPath,
198-
<String>['test_vm_service_bonjour_service'],
199-
environment: <String, String>{
200-
'CONFIGURATION': 'Debug',
201-
'BUILT_PRODUCTS_DIR': buildDirectory.path,
202-
'INFOPLIST_PATH': 'Info.plist',
203-
'DISABLE_PORT_PUBLICATION': 'YES',
204-
},
205-
);
206-
207-
expect(infoPlist.readAsStringSync().contains('NSBonjourServices'), isFalse);
208-
expect(infoPlist.readAsStringSync().contains('NSLocalNetworkUsageDescription'), isFalse);
209-
expect(result, const ProcessResultMatcher());
210-
});
211186
}, skip: !io.Platform.isMacOS); // [intended] requires macos toolchain.
212187
}

0 commit comments

Comments
 (0)