diff --git a/packages/flutter_tools/lib/src/base/build.dart b/packages/flutter_tools/lib/src/base/build.dart index 8561c92bd6b1f..fe8d3a01185ae 100644 --- a/packages/flutter_tools/lib/src/base/build.dart +++ b/packages/flutter_tools/lib/src/base/build.dart @@ -129,12 +129,17 @@ class AOTSnapshotter { final Directory outputDir = _fileSystem.directory(outputPath); outputDir.createSync(recursive: true); + final List iosGenSnapshotArgs = [ + // 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 genSnapshotArgs = [ // 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 = diff --git a/packages/flutter_tools/lib/src/build_system/targets/ios.dart b/packages/flutter_tools/lib/src/build_system/targets/ios.dart index 19bd6fe110734..bb00faab0333b 100644 --- a/packages/flutter_tools/lib/src/build_system/targets/ios.dart +++ b/packages/flutter_tools/lib/src/build_system/targets/ios.dart @@ -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')); + } } }