Add observatory Bonjour service to built iOS Info.plist bundle (#65138)
This commit is contained in:
@@ -14,8 +14,6 @@ import 'package:path/path.dart' as path;
|
||||
Future<void> main() async {
|
||||
await task(() async {
|
||||
try {
|
||||
bool foundProjectName = false;
|
||||
bool bitcode = false;
|
||||
await runProjectTest((FlutterProject flutterProject) async {
|
||||
section('Build app with with --obfuscate');
|
||||
await inDirectory(flutterProject.rootPath, () async {
|
||||
@@ -52,6 +50,13 @@ Future<void> main() async {
|
||||
fail('Failed to produce expected output at ${outputAppFrameworkBinary.path}');
|
||||
}
|
||||
|
||||
if (await dartObservatoryBonjourServiceFound(outputAppPath)) {
|
||||
throw TaskResult.failure('Release bundle has unexpected NSBonjourServices');
|
||||
}
|
||||
if (await localNetworkUsageFound(outputAppPath)) {
|
||||
throw TaskResult.failure('Release bundle has unexpected NSLocalNetworkUsageDescription');
|
||||
}
|
||||
|
||||
section('Validate obfuscation');
|
||||
|
||||
// Verify that an identifier from the Dart project code is not present
|
||||
@@ -63,11 +68,11 @@ Future<void> main() async {
|
||||
canFail: true,
|
||||
);
|
||||
if (response.trim().contains('matches')) {
|
||||
foundProjectName = true;
|
||||
throw TaskResult.failure('Found project name in obfuscated dart library');
|
||||
}
|
||||
});
|
||||
|
||||
section('Validate bitcode');
|
||||
section('Validate release contents');
|
||||
|
||||
final Directory outputFlutterFramework = Directory(path.join(
|
||||
flutterProject.rootPath,
|
||||
@@ -83,7 +88,13 @@ Future<void> main() async {
|
||||
if (!outputFlutterFrameworkBinary.existsSync()) {
|
||||
fail('Failed to produce expected output at ${outputFlutterFrameworkBinary.path}');
|
||||
}
|
||||
bitcode = await containsBitcode(outputFlutterFrameworkBinary.path);
|
||||
|
||||
// Archiving should contain a bitcode blob, but not building in release.
|
||||
// This mimics Xcode behavior and present a developer from having to install a
|
||||
// 300+MB app to test devices.
|
||||
if (await containsBitcode(outputFlutterFrameworkBinary.path)) {
|
||||
throw TaskResult.failure('Bitcode present in Flutter.framework');
|
||||
}
|
||||
|
||||
section('Xcode backend script');
|
||||
|
||||
@@ -101,7 +112,7 @@ Future<void> main() async {
|
||||
'xcode_backend.sh'
|
||||
);
|
||||
|
||||
// Simulate a commonly Xcode build setting misconfiguration
|
||||
// Simulate a common Xcode build setting misconfiguration
|
||||
// where FLUTTER_APPLICATION_PATH is missing
|
||||
final int result = await exec(
|
||||
xcodeBackendPath,
|
||||
@@ -111,6 +122,7 @@ Future<void> main() async {
|
||||
'TARGET_BUILD_DIR': buildPath,
|
||||
'FRAMEWORKS_FOLDER_PATH': 'Runner.app/Frameworks',
|
||||
'VERBOSE_SCRIPT_LOGGING': '1',
|
||||
'FLUTTER_BUILD_MODE': 'release',
|
||||
'ACTION': 'install', // Skip bitcode stripping since we just checked that above.
|
||||
},
|
||||
);
|
||||
@@ -126,17 +138,35 @@ Future<void> main() async {
|
||||
if (!outputAppFrameworkBinary.existsSync()) {
|
||||
fail('Failed to re-embed ${outputAppFrameworkBinary.path}');
|
||||
}
|
||||
});
|
||||
|
||||
if (foundProjectName) {
|
||||
return TaskResult.failure('Found project name in obfuscated dart library');
|
||||
}
|
||||
// Archiving should contain a bitcode blob, but not building in release.
|
||||
// This mimics Xcode behavior and present a developer from having to install a
|
||||
// 300+MB app to test devices.
|
||||
if (bitcode) {
|
||||
return TaskResult.failure('Bitcode present in Flutter.framework');
|
||||
}
|
||||
section('Clean build');
|
||||
|
||||
await inDirectory(flutterProject.rootPath, () async {
|
||||
await flutter('clean');
|
||||
});
|
||||
|
||||
section('Validate debug contents');
|
||||
|
||||
await inDirectory(flutterProject.rootPath, () async {
|
||||
await flutter('build', options: <String>[
|
||||
'ios',
|
||||
'--debug',
|
||||
'--no-codesign',
|
||||
]);
|
||||
});
|
||||
|
||||
// Debug should also not contain bitcode.
|
||||
if (await containsBitcode(outputFlutterFrameworkBinary.path)) {
|
||||
throw TaskResult.failure('Bitcode present in Flutter.framework');
|
||||
}
|
||||
|
||||
if (!await dartObservatoryBonjourServiceFound(outputAppPath)) {
|
||||
throw TaskResult.failure('Debug bundle is missing NSBonjourServices');
|
||||
}
|
||||
if (!await localNetworkUsageFound(outputAppPath)) {
|
||||
throw TaskResult.failure('Debug bundle is missing NSLocalNetworkUsageDescription');
|
||||
}
|
||||
});
|
||||
|
||||
return TaskResult.success(null);
|
||||
} on TaskResult catch (taskResult) {
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
import 'utils.dart';
|
||||
|
||||
typedef SimulatorFunction = Future<void> Function(String deviceId);
|
||||
@@ -102,6 +104,40 @@ Future<bool> containsBitcode(String pathToBinary) async {
|
||||
return !emptyBitcodeMarkerFound;
|
||||
}
|
||||
|
||||
Future<bool> dartObservatoryBonjourServiceFound(String appBundlePath) async =>
|
||||
(await eval(
|
||||
'plutil',
|
||||
<String>[
|
||||
'-extract',
|
||||
'NSBonjourServices',
|
||||
'xml1',
|
||||
'-o',
|
||||
'-',
|
||||
path.join(
|
||||
appBundlePath,
|
||||
'Info.plist',
|
||||
),
|
||||
],
|
||||
canFail: true,
|
||||
)).contains('_dartobservatory._tcp');
|
||||
|
||||
Future<bool> localNetworkUsageFound(String appBundlePath) async =>
|
||||
await exec(
|
||||
'plutil',
|
||||
<String>[
|
||||
'-extract',
|
||||
'NSLocalNetworkUsageDescription',
|
||||
'xml1',
|
||||
'-o',
|
||||
'-',
|
||||
path.join(
|
||||
appBundlePath,
|
||||
'Info.plist',
|
||||
),
|
||||
],
|
||||
canFail: true,
|
||||
) == 0;
|
||||
|
||||
/// Creates and boots a new simulator, passes the new simulator's identifier to
|
||||
/// `testFunction`.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user