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