Remove Runner target check, prefer schemes (#56620)
diff --git a/packages/flutter_tools/lib/src/ios/code_signing.dart b/packages/flutter_tools/lib/src/ios/code_signing.dart index cce0ae4..ec99325 100644 --- a/packages/flutter_tools/lib/src/ios/code_signing.dart +++ b/packages/flutter_tools/lib/src/ios/code_signing.dart
@@ -13,6 +13,7 @@ import '../base/io.dart'; import '../base/logger.dart'; import '../base/process.dart'; +import '../build_info.dart'; import '../convert.dart' show utf8; import '../globals.dart' as globals; @@ -101,8 +102,9 @@ @required BuildableIOSApp iosApp, @required ProcessManager processManager, @required Logger logger, + @required BuildInfo buildInfo, }) async { - final Map<String, String> buildSettings = await iosApp.project.buildSettings; + final Map<String, String> buildSettings = await iosApp.project.buildSettingsForBuildInfo(buildInfo); if (buildSettings == null) { return null; }
diff --git a/packages/flutter_tools/lib/src/ios/mac.dart b/packages/flutter_tools/lib/src/ios/mac.dart index d3d6e92..f2f088d 100644 --- a/packages/flutter_tools/lib/src/ios/mac.dart +++ b/packages/flutter_tools/lib/src/ios/mac.dart
@@ -111,12 +111,6 @@ await removeFinderExtendedAttributes(app.project.hostAppRoot, processUtils, globals.logger); final XcodeProjectInfo projectInfo = await globals.xcodeProjectInterpreter.getInfo(app.project.hostAppRoot.path); - if (!projectInfo.targets.contains('Runner')) { - globals.printError('The Xcode project does not define target "Runner" which is needed by Flutter tooling.'); - globals.printError('Open Xcode to fix the problem:'); - globals.printError(' open ios/Runner.xcworkspace'); - return XcodeBuildResult(success: false); - } final String scheme = projectInfo.schemeFor(buildInfo); if (scheme == null) { globals.printError(''); @@ -180,7 +174,8 @@ autoSigningConfigs = await getCodeSigningIdentityDevelopmentTeam( iosApp: app, processManager: globals.processManager, - logger: globals.logger + logger: globals.logger, + buildInfo: buildInfo, ); } @@ -229,7 +224,10 @@ } // Check if the project contains a watchOS companion app. - final bool hasWatchCompanion = await app.project.containsWatchCompanion(projectInfo.targets); + final bool hasWatchCompanion = await app.project.containsWatchCompanion( + projectInfo.targets, + buildInfo, + ); if (hasWatchCompanion) { // The -sdk argument has to be omitted if a watchOS companion app exists. // Otherwise the build will fail as WatchKit dependencies cannot be build using the iOS SDK.
diff --git a/packages/flutter_tools/lib/src/ios/xcodeproj.dart b/packages/flutter_tools/lib/src/ios/xcodeproj.dart index 1786508..b2fab77 100644 --- a/packages/flutter_tools/lib/src/ios/xcodeproj.dart +++ b/packages/flutter_tools/lib/src/ios/xcodeproj.dart
@@ -309,9 +309,12 @@ /// Asynchronously retrieve xcode build settings. This one is preferred for /// new call-sites. + /// + /// If [scheme] is null, xcodebuild will return build settings for the first discovered + /// target (by default this is Runner). Future<Map<String, String>> getBuildSettings( - String projectPath, - String target, { + String projectPath, { + String scheme, Duration timeout = const Duration(minutes: 1), }) async { final Status status = Status.withSpinner( @@ -324,8 +327,8 @@ _executable, '-project', _fileSystem.path.absolute(projectPath), - '-target', - target, + if (scheme != null) + ...<String>['-scheme', scheme], '-showBuildSettings', ...environmentVariablesAsXcodeBuildSettings(_platform) ]; @@ -465,7 +468,6 @@ final List<String> buildConfigurations; final List<String> schemes; - bool get definesCustomTargets => !(targets.contains('Runner') && targets.length == 1); bool get definesCustomSchemes => !(schemes.contains('Runner') && schemes.length == 1); bool get definesCustomBuildConfigurations { return !(buildConfigurations.contains('Debug') && @@ -475,7 +477,7 @@ /// The expected scheme for [buildInfo]. static String expectedSchemeFor(BuildInfo buildInfo) { - return toTitleCase(buildInfo.flavor ?? 'runner'); + return toTitleCase(buildInfo?.flavor ?? 'runner'); } /// The expected build configuration for [buildInfo] and [scheme].