diff --git a/packages/flutter_tools/lib/src/ios/code_signing.dart b/packages/flutter_tools/lib/src/ios/code_signing.dart index 647015a3ef..aaacedba5c 100644 --- a/packages/flutter_tools/lib/src/ios/code_signing.dart +++ b/packages/flutter_tools/lib/src/ios/code_signing.dart @@ -41,6 +41,9 @@ You can create a new Provisioning Profile for your project in Xcode for your team by: $fixWithDevelopmentTeamInstruction +It's also possible that a previously installed app with the same Bundle Identifier was +signed with a different certificate. + For more information, please visit: https://flutter.io/setup/#deploy-to-ios-devices @@ -65,8 +68,11 @@ const String fixWithDevelopmentTeamInstruction = ''' open ios/Runner.xcworkspace 2- Select the 'Runner' project in the navigator then the 'Runner' target in the project settings - 3- In the 'General' tab, make sure a 'Development Team' is selected. You may need to add - your Apple ID first. + 3- In the 'General' tab, make sure a 'Development Team' is selected. You may need to + - Log in with your Apple ID in Xcode first + - Ensure you have a valid unique Bundle ID + - Register your device with your Apple Developer Account + - Let Xcode automatically provision a profile for your app 4- Build or run your project again'''; final RegExp _securityFindIdentityDeveloperIdentityExtractionPattern = diff --git a/packages/flutter_tools/lib/src/ios/devices.dart b/packages/flutter_tools/lib/src/ios/devices.dart index 8dc8e18034..e79da6d755 100644 --- a/packages/flutter_tools/lib/src/ios/devices.dart +++ b/packages/flutter_tools/lib/src/ios/devices.dart @@ -16,6 +16,7 @@ import '../build_info.dart'; import '../device.dart'; import '../globals.dart'; import '../protocol_discovery.dart'; +import 'code_signing.dart'; import 'ios_workflow.dart'; import 'mac.dart'; @@ -242,7 +243,11 @@ class IOSDevice extends Device { if (!debuggingOptions.debuggingEnabled) { // If debugging is not enabled, just launch the application and continue. printTrace('Debugging is not enabled'); - installationResult = await runCommandAndStreamOutput(launchCommand, trace: true); + installationResult = await runCommandAndStreamOutput( + launchCommand, + mapFunction: monitorInstallationFailure, + trace: true, + ); } else { // Debugging is enabled, look for the observatory server port post launch. printTrace('Debugging is enabled, connecting to observatory'); @@ -254,7 +259,11 @@ class IOSDevice extends Device { final Future forwardObservatoryUri = observatoryDiscovery.uri; - final Future launch = runCommandAndStreamOutput(launchCommand, trace: true); + final Future launch = runCommandAndStreamOutput( + launchCommand, + mapFunction: monitorInstallationFailure, + trace: true, + ); localObservatoryUri = await launch.then((int result) async { installationResult = result; @@ -331,6 +340,33 @@ class IOSDevice extends Device { @override Future takeScreenshot(File outputFile) => iMobileDevice.takeScreenshot(outputFile); + + // Maps stdout line stream. Must return original line. + String monitorInstallationFailure(String stdout) { + // Installation issues. + if (stdout.contains('Error 0xe8008015') || stdout.contains('Error 0xe8000067')) { + printError(noProvisioningProfileInstruction, emphasis: true); + + // Launch issues. + } else if (stdout.contains('e80000e2')) { + printError(''' +═══════════════════════════════════════════════════════════════════════════════════ +Your device is locked. Unlock your device first before running. +═══════════════════════════════════════════════════════════════════════════════════''', + emphasis: true); + } else if (stdout.contains('Error 0xe8000022')) { + printError(''' +═══════════════════════════════════════════════════════════════════════════════════ +Error launching app. Try launching from within Xcode via: + open ios/Runner.xcworkspace + +Your Xcode version may be too old for your iOS version. +═══════════════════════════════════════════════════════════════════════════════════''', + emphasis: true); + } + + return stdout; + } } class _IOSDeviceLogReader extends DeviceLogReader { diff --git a/packages/flutter_tools/lib/src/ios/mac.dart b/packages/flutter_tools/lib/src/ios/mac.dart index 601edd3c81..644f66a12e 100644 --- a/packages/flutter_tools/lib/src/ios/mac.dart +++ b/packages/flutter_tools/lib/src/ios/mac.dart @@ -354,11 +354,9 @@ Future buildXcodeProject({ Future diagnoseXcodeBuildFailure(XcodeBuildResult result, BuildableIOSApp app) async { if (result.xcodeBuildExecution != null && result.xcodeBuildExecution.buildForPhysicalDevice && - ((result.stdout?.contains('BCEROR') == true && - // May need updating if Xcode changes its outputs. - result.stdout?.contains('Xcode couldn\'t find a provisioning profile matching') == true) - // Error message from ios-deploy for missing provisioning profile. - || result.stdout?.contains('0xe8008015') == true)) { + result.stdout?.contains('BCEROR') == true && + // May need updating if Xcode changes its outputs. + result.stdout?.contains('Xcode couldn\'t find a provisioning profile matching') == true) { printError(noProvisioningProfileInstruction, emphasis: true); return; } diff --git a/packages/flutter_tools/test/ios/mac_test.dart b/packages/flutter_tools/test/ios/mac_test.dart index b32314c832..1681b66d3a 100644 --- a/packages/flutter_tools/test/ios/mac_test.dart +++ b/packages/flutter_tools/test/ios/mac_test.dart @@ -311,33 +311,6 @@ Xcode's output: Could not build the precompiled application for the device. -Error launching application on iPhone.''', - xcodeBuildExecution: new XcodeBuildExecution( - ['xcrun', 'xcodebuild', 'blah'], - '/blah/blah', - buildForPhysicalDevice: true - ), - ); - - await diagnoseXcodeBuildFailure(buildResult, app); - expect( - testLogger.errorText, - contains('No Provisioning Profile was found for your project\'s Bundle Identifier or your device.'), - ); - }); - - testUsingContext('No ios-deploy provisioning profile shows message', () async { - final XcodeBuildResult buildResult = new XcodeBuildResult( - success: false, - stdout: ''' -Launching lib/main.dart on iPhone in debug mode... -Signing iOS app for device deployment using developer identity: "iPhone Developer: test@flutter.io (1122334455)" -Running Xcode build... 1.3s -Installing on iPhone... - -ios-deploy[75050:1892997] [ !! ] Error 0xe8008015: A valid provisioning profile for this executable was not found. AMDeviceSecureInstallApplication(0, device, url, options, install_callback, 0) -Could not install build/ios/iphoneos/Runner.app on 7233072bb988fb4c64429a4d9a092295f9423892. - Error launching application on iPhone.''', xcodeBuildExecution: new XcodeBuildExecution( ['xcrun', 'xcodebuild', 'blah'],