Skip to content
11 changes: 8 additions & 3 deletions packages/flutter_tools/lib/src/base/build.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,17 @@ class AOTSnapshotter {
final Directory outputDir = _fileSystem.directory(outputPath);
outputDir.createSync(recursive: true);

final List<String> iosGenSnapshotArgs = <String>[
// Shorebird dumps the class table information during snapshot compilation which is later used during linking.
'--print_class_table_link_debug_info_to=${_fileSystem.path.join(outputDir.parent.path, 'App.class_table.json')}',
'--print_class_table_link_info_to=${_fileSystem.path.join(outputDir.parent.path, 'App.ct.link')}',
];

final List<String> genSnapshotArgs = <String>[
// Shorebird uses --deterministic to improve snapshot stability and increase linking.
'--deterministic',
// Shorebird dumps the class table information during snapshot compilation.
'--print_class_table_link_debug_info_to=${_fileSystem.path.join(outputDir.path, 'App.class_table.json')}',
'--print_class_table_link_info_to=${_fileSystem.path.join(outputDir.path, 'App.ct.link')}',
// Only use the default Shorebird gen_snapshot args on iOS.
if (platform == TargetPlatform.ios) ...iosGenSnapshotArgs,
];

final bool targetingApplePlatform =
Expand Down
10 changes: 10 additions & 0 deletions packages/flutter_tools/lib/src/build_system/targets/ios.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,16 @@ abstract class AotAssemblyBase extends Target {
// Don't fail if the dSYM wasn't created (i.e. during a debug build).
skipMissingInputs: true,
);

// Copy the class table link information (generated by gen_snapshot) from the buildOutputPath to the iOS build directory.
final File classTableLink = environment.fileSystem.file(environment.fileSystem.path.join(buildOutputPath, 'App.ct.link'));
final File classTableLinkDebug = environment.fileSystem.file(environment.fileSystem.path.join(buildOutputPath, 'App.class_table.json'));
if (classTableLink.existsSync()) {
classTableLink.copySync(environment.fileSystem.path.join(getIosBuildDirectory(), 'shorebird', 'App.ct.link'));
}
if (classTableLinkDebug.existsSync()) {
classTableLinkDebug.copySync(environment.fileSystem.path.join(getIosBuildDirectory(), 'shorebird', 'App.class_table.json'));
}
}
}

Expand Down
Loading