Guess sign iOS with the first certificate when running in machine mode (#10870)
* Guess sign with the first certificate when multiple are available in machine mode * review
This commit is contained in:
@@ -341,6 +341,7 @@ class AndroidDevice extends Device {
|
||||
String kernelPath,
|
||||
bool prebuiltApplication: false,
|
||||
bool applicationNeedsRebuild: false,
|
||||
bool usesTerminalUi: true,
|
||||
}) async {
|
||||
if (!await _checkForSupportedAdbVersion() || !await _checkForSupportedAndroidVersion())
|
||||
return new LaunchResult.failed();
|
||||
|
||||
@@ -260,6 +260,7 @@ Future<LaunchResult> _startApp(DriveCommand command) async {
|
||||
diagnosticPort: command.diagnosticPort,
|
||||
),
|
||||
platformArgs: platformArgs,
|
||||
usesTerminalUi: false,
|
||||
);
|
||||
|
||||
if (!result.started) {
|
||||
|
||||
@@ -222,6 +222,11 @@ abstract class Device {
|
||||
///
|
||||
/// [platformArgs] allows callers to pass platform-specific arguments to the
|
||||
/// start call. The build mode is not used by all platforms.
|
||||
///
|
||||
/// If [usesTerminalUi] is true, Flutter Tools may attempt to prompt the
|
||||
/// user to resolve fixable issues such as selecting a signing certificate
|
||||
/// for iOS device deployment. Set to false if stdin cannot be read from while
|
||||
/// attempting to start the app.
|
||||
Future<LaunchResult> startApp(
|
||||
ApplicationPackage package,
|
||||
BuildMode mode, {
|
||||
@@ -231,7 +236,8 @@ abstract class Device {
|
||||
Map<String, dynamic> platformArgs,
|
||||
String kernelPath,
|
||||
bool prebuiltApplication: false,
|
||||
bool applicationNeedsRebuild: false
|
||||
bool applicationNeedsRebuild: false,
|
||||
bool usesTerminalUi: true,
|
||||
});
|
||||
|
||||
/// Does this device implement support for hot reloading / restarting?
|
||||
|
||||
@@ -68,6 +68,7 @@ class FuchsiaDevice extends Device {
|
||||
bool prebuiltApplication: false,
|
||||
String kernelPath,
|
||||
bool applicationNeedsRebuild: false,
|
||||
bool usesTerminalUi: false,
|
||||
}) => new Future<Null>.error('unimplemented');
|
||||
|
||||
@override
|
||||
|
||||
@@ -80,7 +80,7 @@ final RegExp _certificateOrganizationalUnitExtractionPattern = new RegExp(r'OU=(
|
||||
///
|
||||
/// Will return null if none are found, if the user cancels or if the Xcode
|
||||
/// project has a development team set in the project's build settings.
|
||||
Future<String> getCodeSigningIdentityDevelopmentTeam(BuildableIOSApp iosApp) async{
|
||||
Future<String> getCodeSigningIdentityDevelopmentTeam({BuildableIOSApp iosApp, bool usesTerminalUi: true}) async{
|
||||
if (iosApp.buildSettings == null)
|
||||
return null;
|
||||
|
||||
@@ -115,7 +115,7 @@ Future<String> getCodeSigningIdentityDevelopmentTeam(BuildableIOSApp iosApp) asy
|
||||
.toSet() // Unique.
|
||||
.toList();
|
||||
|
||||
final String signingIdentity = await _chooseSigningIdentity(validCodeSigningIdentities);
|
||||
final String signingIdentity = await _chooseSigningIdentity(validCodeSigningIdentities, usesTerminalUi);
|
||||
|
||||
// If none are chosen, return null.
|
||||
if (signingIdentity == null)
|
||||
@@ -153,7 +153,7 @@ Future<String> getCodeSigningIdentityDevelopmentTeam(BuildableIOSApp iosApp) asy
|
||||
?.group(1);
|
||||
}
|
||||
|
||||
Future<String> _chooseSigningIdentity(List<String> validCodeSigningIdentities) async {
|
||||
Future<String> _chooseSigningIdentity(List<String> validCodeSigningIdentities, bool usesTerminalUi) async {
|
||||
// The user has no valid code signing identities.
|
||||
if (validCodeSigningIdentities.isEmpty) {
|
||||
printError(noCertificatesInstruction, emphasis: true);
|
||||
@@ -176,6 +176,11 @@ Future<String> _chooseSigningIdentity(List<String> validCodeSigningIdentities) a
|
||||
}
|
||||
}
|
||||
|
||||
// If terminal UI can't be used, just attempt with the first valid certificate
|
||||
// since we can't ask the user.
|
||||
if (!usesTerminalUi)
|
||||
return validCodeSigningIdentities.first;
|
||||
|
||||
final int count = validCodeSigningIdentities.length;
|
||||
printStatus(
|
||||
'Multiple valid development certificates available (your choice will be saved):',
|
||||
|
||||
@@ -175,13 +175,20 @@ class IOSDevice extends Device {
|
||||
bool prebuiltApplication: false,
|
||||
String kernelPath,
|
||||
bool applicationNeedsRebuild: false,
|
||||
bool usesTerminalUi: true,
|
||||
}) async {
|
||||
if (!prebuiltApplication) {
|
||||
// TODO(chinmaygarde): Use mainPath, route.
|
||||
printTrace('Building ${app.name} for $id');
|
||||
|
||||
// Step 1: Build the precompiled/DBC application if necessary.
|
||||
final XcodeBuildResult buildResult = await buildXcodeProject(app: app, mode: mode, target: mainPath, buildForDevice: true);
|
||||
final XcodeBuildResult buildResult = await buildXcodeProject(
|
||||
app: app,
|
||||
mode: mode,
|
||||
target: mainPath,
|
||||
buildForDevice: true,
|
||||
usesTerminalUi: usesTerminalUi,
|
||||
);
|
||||
if (!buildResult.success) {
|
||||
printError('Could not build the precompiled application for the device.');
|
||||
await diagnoseXcodeBuildFailure(buildResult, app);
|
||||
|
||||
@@ -193,7 +193,8 @@ Future<XcodeBuildResult> buildXcodeProject({
|
||||
BuildMode mode,
|
||||
String target: flx.defaultMainPath,
|
||||
bool buildForDevice,
|
||||
bool codesign: true
|
||||
bool codesign: true,
|
||||
bool usesTerminalUi: true,
|
||||
}) async {
|
||||
if (!_checkXcodeVersion())
|
||||
return new XcodeBuildResult(success: false);
|
||||
@@ -205,7 +206,7 @@ Future<XcodeBuildResult> buildXcodeProject({
|
||||
|
||||
String developmentTeam;
|
||||
if (codesign && buildForDevice)
|
||||
developmentTeam = await getCodeSigningIdentityDevelopmentTeam(app);
|
||||
developmentTeam = await getCodeSigningIdentityDevelopmentTeam(iosApp: app, usesTerminalUi: usesTerminalUi);
|
||||
|
||||
// Before the build, all service definitions must be updated and the dylibs
|
||||
// copied over to a location that is suitable for Xcodebuild to find them.
|
||||
|
||||
@@ -315,6 +315,7 @@ class IOSSimulator extends Device {
|
||||
String kernelPath,
|
||||
bool prebuiltApplication: false,
|
||||
bool applicationNeedsRebuild: false,
|
||||
bool usesTerminalUi: true,
|
||||
}) async {
|
||||
if (!prebuiltApplication) {
|
||||
printTrace('Building ${app.name} for $id.');
|
||||
|
||||
@@ -239,7 +239,8 @@ class FlutterDevice {
|
||||
route: route,
|
||||
prebuiltApplication: prebuiltMode,
|
||||
kernelPath: hotRunner.kernelFilePath,
|
||||
applicationNeedsRebuild: shouldBuild || hasDirtyDependencies
|
||||
applicationNeedsRebuild: shouldBuild || hasDirtyDependencies,
|
||||
usesTerminalUi: hotRunner.usesTerminalUI,
|
||||
);
|
||||
|
||||
final LaunchResult result = await futureResult;
|
||||
@@ -298,7 +299,8 @@ class FlutterDevice {
|
||||
platformArgs: platformArgs,
|
||||
route: route,
|
||||
prebuiltApplication: prebuiltMode,
|
||||
applicationNeedsRebuild: shouldBuild || hasDirtyDependencies
|
||||
applicationNeedsRebuild: shouldBuild || hasDirtyDependencies,
|
||||
usesTerminalUi: coldRunner.usesTerminalUI,
|
||||
);
|
||||
|
||||
if (!result.started) {
|
||||
|
||||
Reference in New Issue
Block a user