Save development certificate choice (#10849)
This commit is contained in:
@@ -13,6 +13,11 @@ class ConfigCommand extends FlutterCommand {
|
||||
argParser.addFlag('analytics',
|
||||
negatable: true,
|
||||
help: 'Enable or disable reporting anonymously tool usage statistics and crash reports.');
|
||||
argParser.addFlag(
|
||||
'clear-ios-signing-cert',
|
||||
negatable: false,
|
||||
help: 'Clear the saved development certificate choice used to sign apps for iOS device deployment'
|
||||
);
|
||||
argParser.addOption('gradle-dir', help: 'The gradle install directory.');
|
||||
argParser.addOption('android-studio-dir', help: 'The Android Studio install directory.');
|
||||
}
|
||||
@@ -60,6 +65,9 @@ class ConfigCommand extends FlutterCommand {
|
||||
if (argResults.wasParsed('android-studio-dir'))
|
||||
_updateConfig('android-studio-dir', argResults['android-studio-dir']);
|
||||
|
||||
if (argResults.wasParsed('clear-ios-signing-cert'))
|
||||
_updateConfig('ios-signing-cert', '');
|
||||
|
||||
if (argResults.arguments.isEmpty)
|
||||
printStatus(usage);
|
||||
}
|
||||
|
||||
@@ -164,9 +164,21 @@ Future<String> _chooseSigningIdentity(List<String> validCodeSigningIdentities) a
|
||||
return validCodeSigningIdentities.first;
|
||||
|
||||
if (validCodeSigningIdentities.length > 1) {
|
||||
final String savedCertChoice = config.getValue('ios-signing-cert');
|
||||
|
||||
if (savedCertChoice != null) {
|
||||
if (validCodeSigningIdentities.contains(savedCertChoice)) {
|
||||
printStatus('Found saved certificate choice "$savedCertChoice". To clear, use "flutter config".');
|
||||
return savedCertChoice;
|
||||
}
|
||||
else {
|
||||
printError('Saved signing certificate "$savedCertChoice" is not a valid development certificate');
|
||||
}
|
||||
}
|
||||
|
||||
final int count = validCodeSigningIdentities.length;
|
||||
printStatus(
|
||||
'Multiple valid development certificates available:',
|
||||
'Multiple valid development certificates available (your choice will be saved):',
|
||||
emphasis: true,
|
||||
);
|
||||
for (int i=0; i<count; i++) {
|
||||
@@ -182,10 +194,14 @@ Future<String> _chooseSigningIdentity(List<String> validCodeSigningIdentities) a
|
||||
defaultChoiceIndex: 0, // Just pressing enter chooses the first one.
|
||||
);
|
||||
|
||||
if (choice == 'a')
|
||||
if (choice == 'a') {
|
||||
throwToolExit('Aborted. Code signing is required to build a deployable iOS app.');
|
||||
else
|
||||
return validCodeSigningIdentities[int.parse(choice) - 1];
|
||||
} else {
|
||||
final String selectedCert = validCodeSigningIdentities[int.parse(choice) - 1];
|
||||
printStatus('Certificate choice "$savedCertChoice" saved');
|
||||
config.setValue('ios-signing-cert', selectedCert);
|
||||
return selectedCert;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user