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.
This commit is contained in:
parent
f629dc8771
commit
367203b301
@ -152,7 +152,7 @@ class AnalyzeCommand extends FlutterCommand {
|
||||
argParser.addFlag('output-universal-link-settings',
|
||||
negatable: false,
|
||||
help: 'Output a JSON with iOS Xcode universal link settings into a file. '
|
||||
'The "--configuration", "--scheme", and "--target" must also be set.',
|
||||
'The "--configuration" and "--target" must be set.',
|
||||
hide: !verboseHelp,
|
||||
);
|
||||
|
||||
@ -162,12 +162,6 @@ class AnalyzeCommand extends FlutterCommand {
|
||||
hide: !verboseHelp,
|
||||
);
|
||||
|
||||
argParser.addOption('scheme',
|
||||
help: 'Sets the iOS build scheme to be analyzed.',
|
||||
valueHelp: 'scheme',
|
||||
hide: !verboseHelp,
|
||||
);
|
||||
|
||||
argParser.addOption('target',
|
||||
help: 'Sets the iOS build target to be analyzed.',
|
||||
valueHelp: 'target',
|
||||
@ -264,7 +258,6 @@ class AnalyzeCommand extends FlutterCommand {
|
||||
final IOSAnalyzeOption option;
|
||||
final String? configuration;
|
||||
final String? target;
|
||||
final String? scheme;
|
||||
if (argResults!['list-build-options'] as bool && argResults!['output-universal-link-settings'] as bool) {
|
||||
throwToolExit('Only one of "--list-build-options" or "--output-universal-link-settings" can be provided');
|
||||
}
|
||||
@ -272,7 +265,6 @@ class AnalyzeCommand extends FlutterCommand {
|
||||
option = IOSAnalyzeOption.listBuildOptions;
|
||||
configuration = null;
|
||||
target = null;
|
||||
scheme = null;
|
||||
} else if (argResults!['output-universal-link-settings'] as bool) {
|
||||
option = IOSAnalyzeOption.outputUniversalLinkSettings;
|
||||
configuration = argResults!['configuration'] as String?;
|
||||
@ -283,10 +275,6 @@ class AnalyzeCommand extends FlutterCommand {
|
||||
if (target == null) {
|
||||
throwToolExit('"--target" must be provided');
|
||||
}
|
||||
scheme = argResults!['scheme'] as String?;
|
||||
if (scheme == null) {
|
||||
throwToolExit('"--scheme" must be provided');
|
||||
}
|
||||
} else {
|
||||
throwToolExit('No argument is provided to analyze. Use -h to see available commands.');
|
||||
}
|
||||
@ -304,7 +292,6 @@ class AnalyzeCommand extends FlutterCommand {
|
||||
option: option,
|
||||
configuration: configuration,
|
||||
target: target,
|
||||
scheme: scheme,
|
||||
logger: _logger,
|
||||
).analyze();
|
||||
} else if (boolArg('suggestions')) {
|
||||
|
@ -15,7 +15,7 @@ enum IOSAnalyzeOption {
|
||||
///
|
||||
/// An example output:
|
||||
///
|
||||
/// {"configurations":["Debug","Release","Profile"],"schemes":["Runner"],"targets":["Runner","RunnerTests"]}
|
||||
/// {"configurations":["Debug","Release","Profile"],"targets":["Runner","RunnerTests"]}
|
||||
listBuildOptions,
|
||||
|
||||
/// Outputs universal link settings of the iOS Xcode sub-project into a file.
|
||||
@ -32,16 +32,14 @@ class IOSAnalyze {
|
||||
required this.project,
|
||||
required this.option,
|
||||
this.configuration,
|
||||
this.scheme,
|
||||
this.target,
|
||||
required this.logger,
|
||||
}) : assert(option == IOSAnalyzeOption.listBuildOptions ||
|
||||
(configuration != null && scheme != null && target != null));
|
||||
(configuration != null && target != null));
|
||||
|
||||
final FlutterProject project;
|
||||
final IOSAnalyzeOption option;
|
||||
final String? configuration;
|
||||
final String? scheme;
|
||||
final String? target;
|
||||
final Logger logger;
|
||||
|
||||
@ -55,14 +53,15 @@ class IOSAnalyze {
|
||||
} else {
|
||||
result = <String, List<String>>{
|
||||
'configurations': info.buildConfigurations,
|
||||
'schemes': info.schemes,
|
||||
'targets': info.targets,
|
||||
};
|
||||
}
|
||||
logger.printStatus(jsonEncode(result));
|
||||
case IOSAnalyzeOption.outputUniversalLinkSettings:
|
||||
await project.ios.outputsUniversalLinkSettings(configuration: configuration!, scheme: scheme!, target: target!);
|
||||
final String filePath = await project.ios.outputsUniversalLinkSettings(configuration: configuration!, scheme: scheme!, target: target!);
|
||||
final String filePath = await project.ios.outputsUniversalLinkSettings(
|
||||
configuration: configuration!,
|
||||
target: target!,
|
||||
);
|
||||
logger.printStatus('result saved in $filePath');
|
||||
}
|
||||
}
|
||||
|
@ -221,18 +221,17 @@ class IosProject extends XcodeBasedProject {
|
||||
/// The return future will resolve to string path to the output file.
|
||||
Future<String> outputsUniversalLinkSettings({
|
||||
required String configuration,
|
||||
required String scheme,
|
||||
required String target,
|
||||
}) async {
|
||||
final XcodeProjectBuildContext context = XcodeProjectBuildContext(
|
||||
configuration: configuration,
|
||||
scheme: scheme,
|
||||
target: target,
|
||||
);
|
||||
final File file = await parent.buildDirectory
|
||||
.childDirectory('deeplink_data')
|
||||
.childFile('universal-link-settings-$configuration-$scheme-$target.json')
|
||||
.childFile('universal-link-settings-$configuration-$target.json')
|
||||
.create(recursive: true);
|
||||
|
||||
await file.writeAsString(jsonEncode(<String, Object?>{
|
||||
'bundleIdentifier': await _productBundleIdentifierWithBuildContext(context),
|
||||
'teamIdentifier': await _getTeamIdentifier(context),
|
||||
|
@ -68,21 +68,18 @@ void main() {
|
||||
final MockIosProject ios = MockIosProject();
|
||||
final MockFlutterProject project = MockFlutterProject(ios);
|
||||
const String expectedConfig = 'someConfig';
|
||||
const String expectedScheme = 'someScheme';
|
||||
const String expectedTarget = 'someConfig';
|
||||
const String expectedTarget = 'someTarget';
|
||||
const String expectedOutputFile = '/someFile';
|
||||
ios.outputFileLocation = expectedOutputFile;
|
||||
await IOSAnalyze(
|
||||
project: project,
|
||||
option: IOSAnalyzeOption.outputUniversalLinkSettings,
|
||||
configuration: expectedConfig,
|
||||
scheme: expectedScheme,
|
||||
target: expectedTarget,
|
||||
logger: logger,
|
||||
).analyze();
|
||||
expect(logger.statusText, contains(expectedOutputFile));
|
||||
expect(ios.outputConfiguration, expectedConfig);
|
||||
expect(ios.outputScheme, expectedScheme);
|
||||
expect(ios.outputTarget, expectedTarget);
|
||||
});
|
||||
|
||||
@ -91,8 +88,7 @@ void main() {
|
||||
final MockFlutterProject project = MockFlutterProject(ios);
|
||||
const List<String> targets = <String>['target1', 'target2'];
|
||||
const List<String> configs = <String>['config1', 'config2'];
|
||||
const List<String> schemes = <String>['scheme1', 'scheme2'];
|
||||
ios.expectedProjectInfo = XcodeProjectInfo(targets, configs, schemes, logger);
|
||||
ios.expectedProjectInfo = XcodeProjectInfo(targets, configs, const <String>[], logger);
|
||||
await IOSAnalyze(
|
||||
project: project,
|
||||
option: IOSAnalyzeOption.listBuildOptions,
|
||||
@ -101,7 +97,6 @@ void main() {
|
||||
final Map<String, Object?> jsonOutput = jsonDecode(logger.statusText) as Map<String, Object?>;
|
||||
expect(jsonOutput['targets'], unorderedEquals(targets));
|
||||
expect(jsonOutput['configurations'], unorderedEquals(configs));
|
||||
expect(jsonOutput['schemes'], unorderedEquals(schemes));
|
||||
});
|
||||
|
||||
testUsingContext('throws if provide multiple path', () async {
|
||||
@ -144,15 +139,13 @@ class MockFlutterProject extends Fake implements FlutterProject {
|
||||
|
||||
class MockIosProject extends Fake implements IosProject {
|
||||
String? outputConfiguration;
|
||||
String? outputScheme;
|
||||
String? outputTarget;
|
||||
late String outputFileLocation;
|
||||
late XcodeProjectInfo expectedProjectInfo;
|
||||
|
||||
@override
|
||||
Future<String> outputsUniversalLinkSettings({required String configuration, required String scheme, required String target}) async {
|
||||
Future<String> outputsUniversalLinkSettings({required String configuration, required String target}) async {
|
||||
outputConfiguration = configuration;
|
||||
outputScheme = scheme;
|
||||
outputTarget = target;
|
||||
return outputFileLocation;
|
||||
}
|
||||
|
@ -733,7 +733,6 @@ apply plugin: 'kotlin-android'
|
||||
|
||||
const XcodeProjectBuildContext buildContext = XcodeProjectBuildContext(
|
||||
target: 'Runner',
|
||||
scheme: 'Debug',
|
||||
configuration: 'config',
|
||||
);
|
||||
xcodeProjectInterpreter.buildSettingsByBuildContext[buildContext] = <String, String>{
|
||||
@ -753,7 +752,6 @@ apply plugin: 'kotlin-android'
|
||||
);
|
||||
final String outputFilePath = await project.ios.outputsUniversalLinkSettings(
|
||||
target: 'Runner',
|
||||
scheme: 'Debug',
|
||||
configuration: 'config',
|
||||
);
|
||||
final File outputFile = fs.file(outputFilePath);
|
||||
@ -781,7 +779,6 @@ apply plugin: 'kotlin-android'
|
||||
|
||||
const XcodeProjectBuildContext buildContext = XcodeProjectBuildContext(
|
||||
target: 'Runner',
|
||||
scheme: 'Debug',
|
||||
configuration: 'config',
|
||||
);
|
||||
xcodeProjectInterpreter.buildSettingsByBuildContext[buildContext] = <String, String>{
|
||||
@ -802,7 +799,6 @@ apply plugin: 'kotlin-android'
|
||||
|
||||
final String outputFilePath = await project.ios.outputsUniversalLinkSettings(
|
||||
target: 'Runner',
|
||||
scheme: 'Debug',
|
||||
configuration: 'config',
|
||||
);
|
||||
final File outputFile = fs.file(outputFilePath);
|
||||
@ -827,7 +823,6 @@ apply plugin: 'kotlin-android'
|
||||
|
||||
const XcodeProjectBuildContext buildContext = XcodeProjectBuildContext(
|
||||
target: 'Runner',
|
||||
scheme: 'Debug',
|
||||
configuration: 'config',
|
||||
);
|
||||
xcodeProjectInterpreter.buildSettingsByBuildContext[buildContext] = <String, String>{
|
||||
@ -838,7 +833,6 @@ apply plugin: 'kotlin-android'
|
||||
testPlistUtils.setProperty(PlistParser.kCFBundleIdentifierKey, r'$(PRODUCT_BUNDLE_IDENTIFIER)');
|
||||
final String outputFilePath = await project.ios.outputsUniversalLinkSettings(
|
||||
target: 'Runner',
|
||||
scheme: 'Debug',
|
||||
configuration: 'config',
|
||||
);
|
||||
final File outputFile = fs.file(outputFilePath);
|
||||
|
Loading…
x
Reference in New Issue
Block a user