diff --git a/dev/devicelab/bin/tasks/module_test_ios.dart b/dev/devicelab/bin/tasks/module_test_ios.dart index b0875d7ac5..f65b5c3af1 100644 --- a/dev/devicelab/bin/tasks/module_test_ios.dart +++ b/dev/devicelab/bin/tasks/module_test_ios.dart @@ -310,8 +310,38 @@ end }, ); - final File hostPodfileLockFile = File(path.join(objectiveCHostApp.path, 'Podfile.lock')); - final String hostPodfileLockOutput = hostPodfileLockFile.readAsStringSync(); + File hostPodfileLockFile = File(path.join(objectiveCHostApp.path, 'Podfile.lock')); + String hostPodfileLockOutput = hostPodfileLockFile.readAsStringSync(); + if (!hostPodfileLockOutput.contains(':path: "../hello/.ios/Flutter"') + || !hostPodfileLockOutput.contains(':path: "../hello/.ios/Flutter/FlutterPluginRegistrant"') + || !hostPodfileLockOutput.contains(':path: "../hello/.ios/.symlinks/plugins/url_launcher_ios/ios"') + || hostPodfileLockOutput.contains('android_alarm_manager') + || hostPodfileLockOutput.contains(dartPluginName)) { + print(hostPodfileLockOutput); + throw TaskResult.failure('Building host app Podfile.lock does not contain expected pods'); + } + + section('Validate install_flutter_[engine_pod|plugin_pods|application_pod] methods in the Podfile can be executed normally'); + + podfileContent = podfileContent.replaceFirst(''' + install_all_flutter_pods flutter_application_path +''', ''' + install_flutter_engine_pod(flutter_application_path) + install_flutter_plugin_pods(flutter_application_path) + install_flutter_application_pod(flutter_application_path) +'''); + await podfile.writeAsString(podfileContent, flush: true); + + await exec( + 'pod', + ['install'], + environment: { + 'LANG': 'en_US.UTF-8', + }, + ); + + hostPodfileLockFile = File(path.join(objectiveCHostApp.path, 'Podfile.lock')); + hostPodfileLockOutput = hostPodfileLockFile.readAsStringSync(); if (!hostPodfileLockOutput.contains(':path: "../hello/.ios/Flutter"') || !hostPodfileLockOutput.contains(':path: "../hello/.ios/Flutter/FlutterPluginRegistrant"') || !hostPodfileLockOutput.contains(':path: "../hello/.ios/.symlinks/plugins/url_launcher_ios/ios"') diff --git a/packages/flutter_tools/templates/module/ios/library/Flutter.tmpl/podhelper.rb.tmpl b/packages/flutter_tools/templates/module/ios/library/Flutter.tmpl/podhelper.rb.tmpl index b3694eac6e..56742400ac 100644 --- a/packages/flutter_tools/templates/module/ios/library/Flutter.tmpl/podhelper.rb.tmpl +++ b/packages/flutter_tools/templates/module/ios/library/Flutter.tmpl/podhelper.rb.tmpl @@ -28,8 +28,6 @@ POSTINSTALL raise 'Missing `flutter_post_install(installer)` in Podfile `post_install` block' end - require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) - flutter_application_path ||= File.join('..', '..') install_flutter_engine_pod(flutter_application_path) install_flutter_plugin_pods(flutter_application_path) @@ -112,6 +110,8 @@ def flutter_root raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" end +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + # Run the post-install script to set build settings on Flutter plugins. # # @example