From 5a35e1104f6a127661ee0edef965ed74b2edb005 Mon Sep 17 00:00:00 2001 From: Eric Seidel Date: Fri, 2 May 2025 09:59:25 -0700 Subject: [PATCH] feat: add support for dispatch table supplement files (#3081) --- bin/internal/flutter.version | 2 +- .../shorebird_cli/lib/src/platform/apple.dart | 10 +++- .../test/src/platform/apple_test.dart | 51 ++++++++++++++----- 3 files changed, 48 insertions(+), 15 deletions(-) diff --git a/bin/internal/flutter.version b/bin/internal/flutter.version index a374ed8d..65edf7f1 100644 --- a/bin/internal/flutter.version +++ b/bin/internal/flutter.version @@ -1 +1 @@ -0ac69de92c7201830d6a687a44fa0d34f6003f90 +7c1c25e48e6dd849c3264588346aa63652d5e426 diff --git a/packages/shorebird_cli/lib/src/platform/apple.dart b/packages/shorebird_cli/lib/src/platform/apple.dart index 61dc38f3..ded5791b 100644 --- a/packages/shorebird_cli/lib/src/platform/apple.dart +++ b/packages/shorebird_cli/lib/src/platform/apple.dart @@ -135,7 +135,7 @@ class Apple { /// patch builds. Both times it produces supplement files in a directory. /// In the release case, these files are zipped up and stored as an artifact /// on our servers for later use. In the patch case, they were created on - /// disk just before this call. + /// disk just before this call by XCode calling flutter calling gen_snapshot. /// In both cases we need to copy the supplement files from these directories /// to right next to where the snapshot files are before calling into /// `aot_tools` to link the two snapshots together. @@ -153,13 +153,19 @@ class Apple { 'App.class_table.json', 'App.ft.link', 'App.field_table.json', + 'App.dt.link', + 'App.dispatch_table.json', ]; // This uses maybeCopy because not all versions of gen_snapshot/aot_tools // use the same supplement files. At the `shorebird` level we don't know // which files should be present, so we just try to copy all. void maybeCopy(File file, Directory destDir, {String? newBaseName}) { - if (!file.existsSync()) return; + logger.detail('Copying supplement file ${file.path} to ${destDir.path}'); + if (!file.existsSync()) { + logger.detail('Unable to find supplement file at ${file.path}'); + return; + } final baseName = p.basename(file.path); final destName = newBaseName != null diff --git a/packages/shorebird_cli/test/src/platform/apple_test.dart b/packages/shorebird_cli/test/src/platform/apple_test.dart index 822efc83..c1e1d4ce 100644 --- a/packages/shorebird_cli/test/src/platform/apple_test.dart +++ b/packages/shorebird_cli/test/src/platform/apple_test.dart @@ -103,8 +103,10 @@ To add macOS, run "flutter create . --platforms macos"'''); test('copies all files next to snapshots', () { final names = [ 'App.class_table.json', + 'App.dispatch_table.json', 'App.field_table.json', 'App.ct.link', + 'App.dt.link', 'App.ft.link', ]; @@ -121,14 +123,16 @@ To add macOS, run "flutter create . --platforms macos"'''); final releaseSnapshotDir = Directory.systemTemp.createTempSync(); final patchSnapshotDir = Directory.systemTemp.createTempSync(); - apple.copySupplementFilesToSnapshotDirs( - releaseSupplementDir: releaseSupplementDir, - releaseSnapshotDir: releaseSnapshotDir, - patchSupplementDir: patchSupplementDir, - patchSnapshotDir: patchSnapshotDir, + runWithOverrides( + () => apple.copySupplementFilesToSnapshotDirs( + releaseSupplementDir: releaseSupplementDir, + releaseSnapshotDir: releaseSnapshotDir, + patchSupplementDir: patchSupplementDir, + patchSnapshotDir: patchSnapshotDir, + ), ); - expect(Directory(releaseSnapshotDir.path).listSync(), hasLength(4)); - expect(Directory(patchSnapshotDir.path).listSync(), hasLength(4)); + expect(Directory(releaseSnapshotDir.path).listSync(), hasLength(6)); + expect(Directory(patchSnapshotDir.path).listSync(), hasLength(6)); }); test('copies only some files next to snapshots', () { @@ -147,14 +151,37 @@ To add macOS, run "flutter create . --platforms macos"'''); final releaseSnapshotDir = Directory.systemTemp.createTempSync(); final patchSnapshotDir = Directory.systemTemp.createTempSync(); - apple.copySupplementFilesToSnapshotDirs( - releaseSupplementDir: releaseSupplementDir, - releaseSnapshotDir: releaseSnapshotDir, - patchSupplementDir: patchSupplementDir, - patchSnapshotDir: patchSnapshotDir, + runWithOverrides( + () => apple.copySupplementFilesToSnapshotDirs( + releaseSupplementDir: releaseSupplementDir, + releaseSnapshotDir: releaseSnapshotDir, + patchSupplementDir: patchSupplementDir, + patchSnapshotDir: patchSnapshotDir, + ), ); expect(Directory(releaseSnapshotDir.path).listSync(), hasLength(2)); expect(Directory(patchSnapshotDir.path).listSync(), hasLength(2)); + + // Logs when copying files. + final classTableFilePath = p.join( + releaseSupplementDir.path, + 'App.class_table.json', + ); + verify( + () => logger.detail( + 'Copying supplement file $classTableFilePath to ${releaseSnapshotDir.path}', + ), + ).called(1); + // Logs about missing files + final dispatchTableFilePath = p.join( + releaseSupplementDir.path, + 'App.dispatch_table.json', + ); + verify( + () => logger.detail( + 'Unable to find supplement file at $dispatchTableFilePath', + ), + ).called(1); }); });