diff --git a/packages/flutter_tools/lib/src/project.dart b/packages/flutter_tools/lib/src/project.dart index cf7e0bb8c1..4e4e4e02e4 100644 --- a/packages/flutter_tools/lib/src/project.dart +++ b/packages/flutter_tools/lib/src/project.dart @@ -138,9 +138,16 @@ class FlutterProject { // Don't require iOS build info, this method is only // used during create as best-effort, use the // default target bundle identifier. - final String? bundleIdentifier = await ios.productBundleIdentifier(null); - if (bundleIdentifier != null) { - candidates.add(bundleIdentifier); + try { + final String? bundleIdentifier = await ios.productBundleIdentifier(null); + if (bundleIdentifier != null) { + candidates.add(bundleIdentifier); + } + } on ToolExit { + // It's possible that while parsing the build info for the ios project + // that the bundleIdentifier can't be resolve. However, we would like + // skip parsing that id in favor of searching in other place. We can + // consider a tool exit in this case to be non fatal for the program. } } if (android.existsSync()) { diff --git a/packages/flutter_tools/test/general.shard/project_test.dart b/packages/flutter_tools/test/general.shard/project_test.dart index 4900dc1b9d..27ab853701 100644 --- a/packages/flutter_tools/test/general.shard/project_test.dart +++ b/packages/flutter_tools/test/general.shard/project_test.dart @@ -509,6 +509,17 @@ apply plugin: 'kotlin-android' expect(await project.ios.productBundleIdentifier(null), 'io.flutter.someProject.suffix'); }); + testWithMocks('Always pass parsing org on ios project with flavors', () async { + final FlutterProject project = await someProject(); + addIosProjectFile(project.directory, projectFileContent: () { + return projectFileWithBundleId('io.flutter.someProject', qualifier: "'"); + }); + project.ios.xcodeProject.createSync(); + xcodeProjectInterpreter.xcodeProjectInfo = XcodeProjectInfo([], [], ['free', 'paid'], logger); + + expect(await project.organizationNames, []); + }); + testWithMocks('fails with no flavor and defined schemes', () async { final FlutterProject project = await someProject(); project.ios.xcodeProject.createSync();