Enable Swift Package Manager by default on master channel (#152049)

Changes:

1. Enables Swift Package Manager by default on the main/master channel
2. Fixes tests that fail if Swift Package Manager is enabled

Corresponding docs change: https://github.com/flutter/website/pull/10938

Addresses https://github.com/flutter/flutter/issues/151567
This commit is contained in:
Loïc Sharma
2024-07-24 09:24:31 -07:00
committed by GitHub
parent 0d504914c7
commit 08d8a7fa81
9 changed files with 215 additions and 85 deletions

View File

@@ -151,7 +151,7 @@ Future<void> _testBuildIosFramework(Directory projectDir, { bool isModule = fals
section('Check debug build has no Dart AOT');
final String aotSymbols = await _dylibSymbols(debugAppFrameworkPath);
final String aotSymbols = await dumpSymbolTable(debugAppFrameworkPath);
if (aotSymbols.contains('architecture') ||
aotSymbols.contains('_kDartVmSnapshot')) {
@@ -172,7 +172,7 @@ Future<void> _testBuildIosFramework(Directory projectDir, { bool isModule = fals
await _checkDylib(appFrameworkPath);
final String aotSymbols = await _dylibSymbols(appFrameworkPath);
final String aotSymbols = await dumpSymbolTable(appFrameworkPath);
if (!aotSymbols.contains('_kDartVmSnapshot')) {
throw TaskResult.failure('$mode App.framework missing Dart AOT');
@@ -562,7 +562,7 @@ Future<void> _testBuildMacOSFramework(Directory projectDir) async {
section('Check debug build has no Dart AOT');
final String aotSymbols = await _dylibSymbols(debugAppFrameworkPath);
final String aotSymbols = await dumpSymbolTable(debugAppFrameworkPath);
if (aotSymbols.contains('architecture') ||
aotSymbols.contains('_kDartVmSnapshot')) {
@@ -583,7 +583,7 @@ Future<void> _testBuildMacOSFramework(Directory projectDir) async {
await _checkDylib(appFrameworkPath);
final String aotSymbols = await _dylibSymbols(appFrameworkPath);
final String aotSymbols = await dumpSymbolTable(appFrameworkPath);
if (!aotSymbols.contains('_kDartVmSnapshot')) {
throw TaskResult.failure('$mode App.framework missing Dart AOT');
@@ -939,15 +939,6 @@ Future<void> _checkStatic(String pathToLibrary) async {
}
}
Future<String> _dylibSymbols(String pathToDylib) {
return eval('nm', <String>[
'-g',
pathToDylib,
'-arch',
'arm64',
]);
}
Future<bool> _linksOnFlutter(String pathToBinary) async {
final String loadCommands = await eval('otool', <String>[
'-l',

View File

@@ -703,13 +703,7 @@ Future<bool> _isAppAotBuild(Directory app) async {
'App',
);
final String symbolTable = await eval(
'nm',
<String> [
'-gU',
binary,
],
);
final String symbolTable = await dumpSymbolTable(binary);
return symbolTable.contains('kDartIsolateSnapshotInstructions');
}

View File

@@ -6,6 +6,7 @@ import 'dart:convert';
import 'dart:io';
import 'package:flutter_devicelab/framework/framework.dart';
import 'package:flutter_devicelab/framework/ios.dart';
import 'package:flutter_devicelab/framework/task_result.dart';
import 'package:flutter_devicelab/framework/utils.dart';
import 'package:path/path.dart' as path;
@@ -209,6 +210,7 @@ public class DummyPluginAClass {
final String flutterPluginsDependenciesFileContent = flutterPluginsDependenciesFile.readAsStringSync();
final Map<String, dynamic> jsonContent = json.decode(flutterPluginsDependenciesFileContent) as Map<String, dynamic>;
final bool swiftPackageManagerEnabled = jsonContent['swift_package_manager_enabled'] as bool? ?? false;
// Verify the dependencyGraph object is valid. The rest of the contents of this file are not relevant to the
// dependency graph and are tested by unit tests.
@@ -302,28 +304,35 @@ public class DummyPluginAClass {
return TaskResult.failure('Failed to build plugin A example iOS app');
}
checkDirectoryExists(path.join(
appBundle.path,
'Frameworks',
'plugin_a.framework',
));
checkDirectoryExists(path.join(
appBundle.path,
'Frameworks',
'plugin_b.framework',
));
checkDirectoryExists(path.join(
appBundle.path,
'Frameworks',
'plugin_c.framework',
));
if (swiftPackageManagerEnabled) {
// Check plugins are built statically if using SwiftPM.
final String executable = path.join(appBundle.path, 'Runner');
final String symbols = await dumpSymbolTable(executable);
// Plugin D is Android only and should not be embedded.
checkDirectoryNotExists(path.join(
appBundle.path,
'Frameworks',
'plugin_d.framework',
));
final bool foundA = symbols.contains('plugin_a');
final bool foundB = symbols.contains('plugin_b');
final bool foundC = symbols.contains('plugin_c');
final bool foundD = symbols.contains('plugin_d');
if (!foundA || !foundB || !foundC) {
return TaskResult.failure(
'Failed to find plugins_a, plugin_b, or plugin_c symbols in the app'
);
}
if (foundD) {
return TaskResult.failure(
'Found Android plugin_d symbols in iOS app'
);
}
} else {
// Check plugins are built dynamically if using CocoaPods.
checkDirectoryExists(path.join(appBundle.path, 'Frameworks', 'plugin_a.framework'));
checkDirectoryExists(path.join(appBundle.path, 'Frameworks', 'plugin_b.framework'));
checkDirectoryExists(path.join(appBundle.path, 'Frameworks', 'plugin_c.framework'));
checkDirectoryNotExists(path.join(appBundle.path, 'Frameworks', 'plugin_d.framework'));
}
}
return TaskResult.success(null);