Skip to content

Commit 367203b

Browse files
authored
Makes scheme and target optional parameter when getting universal lin… (#134571)
�k settings the show build settings xcode command can only accept one of the target or scheme flag. Therefore I make them optional.
1 parent f629dc8 commit 367203b

File tree

5 files changed

+12
-40
lines changed

5 files changed

+12
-40
lines changed

packages/flutter_tools/lib/src/commands/analyze.dart

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class AnalyzeCommand extends FlutterCommand {
152152
argParser.addFlag('output-universal-link-settings',
153153
negatable: false,
154154
help: 'Output a JSON with iOS Xcode universal link settings into a file. '
155-
'The "--configuration", "--scheme", and "--target" must also be set.',
155+
'The "--configuration" and "--target" must be set.',
156156
hide: !verboseHelp,
157157
);
158158

@@ -162,12 +162,6 @@ class AnalyzeCommand extends FlutterCommand {
162162
hide: !verboseHelp,
163163
);
164164

165-
argParser.addOption('scheme',
166-
help: 'Sets the iOS build scheme to be analyzed.',
167-
valueHelp: 'scheme',
168-
hide: !verboseHelp,
169-
);
170-
171165
argParser.addOption('target',
172166
help: 'Sets the iOS build target to be analyzed.',
173167
valueHelp: 'target',
@@ -264,15 +258,13 @@ class AnalyzeCommand extends FlutterCommand {
264258
final IOSAnalyzeOption option;
265259
final String? configuration;
266260
final String? target;
267-
final String? scheme;
268261
if (argResults!['list-build-options'] as bool && argResults!['output-universal-link-settings'] as bool) {
269262
throwToolExit('Only one of "--list-build-options" or "--output-universal-link-settings" can be provided');
270263
}
271264
if (argResults!['list-build-options'] as bool) {
272265
option = IOSAnalyzeOption.listBuildOptions;
273266
configuration = null;
274267
target = null;
275-
scheme = null;
276268
} else if (argResults!['output-universal-link-settings'] as bool) {
277269
option = IOSAnalyzeOption.outputUniversalLinkSettings;
278270
configuration = argResults!['configuration'] as String?;
@@ -283,10 +275,6 @@ class AnalyzeCommand extends FlutterCommand {
283275
if (target == null) {
284276
throwToolExit('"--target" must be provided');
285277
}
286-
scheme = argResults!['scheme'] as String?;
287-
if (scheme == null) {
288-
throwToolExit('"--scheme" must be provided');
289-
}
290278
} else {
291279
throwToolExit('No argument is provided to analyze. Use -h to see available commands.');
292280
}
@@ -304,7 +292,6 @@ class AnalyzeCommand extends FlutterCommand {
304292
option: option,
305293
configuration: configuration,
306294
target: target,
307-
scheme: scheme,
308295
logger: _logger,
309296
).analyze();
310297
} else if (boolArg('suggestions')) {

packages/flutter_tools/lib/src/commands/ios_analyze.dart

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ enum IOSAnalyzeOption {
1515
///
1616
/// An example output:
1717
///
18-
/// {"configurations":["Debug","Release","Profile"],"schemes":["Runner"],"targets":["Runner","RunnerTests"]}
18+
/// {"configurations":["Debug","Release","Profile"],"targets":["Runner","RunnerTests"]}
1919
listBuildOptions,
2020

2121
/// Outputs universal link settings of the iOS Xcode sub-project into a file.
@@ -32,16 +32,14 @@ class IOSAnalyze {
3232
required this.project,
3333
required this.option,
3434
this.configuration,
35-
this.scheme,
3635
this.target,
3736
required this.logger,
3837
}) : assert(option == IOSAnalyzeOption.listBuildOptions ||
39-
(configuration != null && scheme != null && target != null));
38+
(configuration != null && target != null));
4039

4140
final FlutterProject project;
4241
final IOSAnalyzeOption option;
4342
final String? configuration;
44-
final String? scheme;
4543
final String? target;
4644
final Logger logger;
4745

@@ -55,14 +53,15 @@ class IOSAnalyze {
5553
} else {
5654
result = <String, List<String>>{
5755
'configurations': info.buildConfigurations,
58-
'schemes': info.schemes,
5956
'targets': info.targets,
6057
};
6158
}
6259
logger.printStatus(jsonEncode(result));
6360
case IOSAnalyzeOption.outputUniversalLinkSettings:
64-
await project.ios.outputsUniversalLinkSettings(configuration: configuration!, scheme: scheme!, target: target!);
65-
final String filePath = await project.ios.outputsUniversalLinkSettings(configuration: configuration!, scheme: scheme!, target: target!);
61+
final String filePath = await project.ios.outputsUniversalLinkSettings(
62+
configuration: configuration!,
63+
target: target!,
64+
);
6665
logger.printStatus('result saved in $filePath');
6766
}
6867
}

packages/flutter_tools/lib/src/xcode_project.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,18 +221,17 @@ class IosProject extends XcodeBasedProject {
221221
/// The return future will resolve to string path to the output file.
222222
Future<String> outputsUniversalLinkSettings({
223223
required String configuration,
224-
required String scheme,
225224
required String target,
226225
}) async {
227226
final XcodeProjectBuildContext context = XcodeProjectBuildContext(
228227
configuration: configuration,
229-
scheme: scheme,
230228
target: target,
231229
);
232230
final File file = await parent.buildDirectory
233231
.childDirectory('deeplink_data')
234-
.childFile('universal-link-settings-$configuration-$scheme-$target.json')
232+
.childFile('universal-link-settings-$configuration-$target.json')
235233
.create(recursive: true);
234+
236235
await file.writeAsString(jsonEncode(<String, Object?>{
237236
'bundleIdentifier': await _productBundleIdentifierWithBuildContext(context),
238237
'teamIdentifier': await _getTeamIdentifier(context),

packages/flutter_tools/test/commands.shard/hermetic/ios_analyze_test.dart

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,18 @@ void main() {
6868
final MockIosProject ios = MockIosProject();
6969
final MockFlutterProject project = MockFlutterProject(ios);
7070
const String expectedConfig = 'someConfig';
71-
const String expectedScheme = 'someScheme';
72-
const String expectedTarget = 'someConfig';
71+
const String expectedTarget = 'someTarget';
7372
const String expectedOutputFile = '/someFile';
7473
ios.outputFileLocation = expectedOutputFile;
7574
await IOSAnalyze(
7675
project: project,
7776
option: IOSAnalyzeOption.outputUniversalLinkSettings,
7877
configuration: expectedConfig,
79-
scheme: expectedScheme,
8078
target: expectedTarget,
8179
logger: logger,
8280
).analyze();
8381
expect(logger.statusText, contains(expectedOutputFile));
8482
expect(ios.outputConfiguration, expectedConfig);
85-
expect(ios.outputScheme, expectedScheme);
8683
expect(ios.outputTarget, expectedTarget);
8784
});
8885

@@ -91,8 +88,7 @@ void main() {
9188
final MockFlutterProject project = MockFlutterProject(ios);
9289
const List<String> targets = <String>['target1', 'target2'];
9390
const List<String> configs = <String>['config1', 'config2'];
94-
const List<String> schemes = <String>['scheme1', 'scheme2'];
95-
ios.expectedProjectInfo = XcodeProjectInfo(targets, configs, schemes, logger);
91+
ios.expectedProjectInfo = XcodeProjectInfo(targets, configs, const <String>[], logger);
9692
await IOSAnalyze(
9793
project: project,
9894
option: IOSAnalyzeOption.listBuildOptions,
@@ -101,7 +97,6 @@ void main() {
10197
final Map<String, Object?> jsonOutput = jsonDecode(logger.statusText) as Map<String, Object?>;
10298
expect(jsonOutput['targets'], unorderedEquals(targets));
10399
expect(jsonOutput['configurations'], unorderedEquals(configs));
104-
expect(jsonOutput['schemes'], unorderedEquals(schemes));
105100
});
106101

107102
testUsingContext('throws if provide multiple path', () async {
@@ -144,15 +139,13 @@ class MockFlutterProject extends Fake implements FlutterProject {
144139

145140
class MockIosProject extends Fake implements IosProject {
146141
String? outputConfiguration;
147-
String? outputScheme;
148142
String? outputTarget;
149143
late String outputFileLocation;
150144
late XcodeProjectInfo expectedProjectInfo;
151145

152146
@override
153-
Future<String> outputsUniversalLinkSettings({required String configuration, required String scheme, required String target}) async {
147+
Future<String> outputsUniversalLinkSettings({required String configuration, required String target}) async {
154148
outputConfiguration = configuration;
155-
outputScheme = scheme;
156149
outputTarget = target;
157150
return outputFileLocation;
158151
}

packages/flutter_tools/test/general.shard/project_test.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,6 @@ apply plugin: 'kotlin-android'
733733

734734
const XcodeProjectBuildContext buildContext = XcodeProjectBuildContext(
735735
target: 'Runner',
736-
scheme: 'Debug',
737736
configuration: 'config',
738737
);
739738
xcodeProjectInterpreter.buildSettingsByBuildContext[buildContext] = <String, String>{
@@ -753,7 +752,6 @@ apply plugin: 'kotlin-android'
753752
);
754753
final String outputFilePath = await project.ios.outputsUniversalLinkSettings(
755754
target: 'Runner',
756-
scheme: 'Debug',
757755
configuration: 'config',
758756
);
759757
final File outputFile = fs.file(outputFilePath);
@@ -781,7 +779,6 @@ apply plugin: 'kotlin-android'
781779

782780
const XcodeProjectBuildContext buildContext = XcodeProjectBuildContext(
783781
target: 'Runner',
784-
scheme: 'Debug',
785782
configuration: 'config',
786783
);
787784
xcodeProjectInterpreter.buildSettingsByBuildContext[buildContext] = <String, String>{
@@ -802,7 +799,6 @@ apply plugin: 'kotlin-android'
802799

803800
final String outputFilePath = await project.ios.outputsUniversalLinkSettings(
804801
target: 'Runner',
805-
scheme: 'Debug',
806802
configuration: 'config',
807803
);
808804
final File outputFile = fs.file(outputFilePath);
@@ -827,7 +823,6 @@ apply plugin: 'kotlin-android'
827823

828824
const XcodeProjectBuildContext buildContext = XcodeProjectBuildContext(
829825
target: 'Runner',
830-
scheme: 'Debug',
831826
configuration: 'config',
832827
);
833828
xcodeProjectInterpreter.buildSettingsByBuildContext[buildContext] = <String, String>{
@@ -838,7 +833,6 @@ apply plugin: 'kotlin-android'
838833
testPlistUtils.setProperty(PlistParser.kCFBundleIdentifierKey, r'$(PRODUCT_BUNDLE_IDENTIFIER)');
839834
final String outputFilePath = await project.ios.outputsUniversalLinkSettings(
840835
target: 'Runner',
841-
scheme: 'Debug',
842836
configuration: 'config',
843837
);
844838
final File outputFile = fs.file(outputFilePath);

0 commit comments

Comments
 (0)