From 70e98213b45557fd2081919f4fc0160c24cf0682 Mon Sep 17 00:00:00 2001
From: Fawzi Mohamed <fawzi.mohamed@digia.com>
Date: Tue, 15 Oct 2013 18:20:24 +0200
Subject: [PATCH] ios: better message for deploy failures
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Change-Id: I0e145b07d034277e2afa74f885a55a2722e2c180
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
Reviewed-by: Topi Reiniö <topi.reinio@digia.com>
---
 src/plugins/ios/iosrunner.cpp | 18 ++++++++++++++----
 src/plugins/ios/iosrunner.h   |  2 +-
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/plugins/ios/iosrunner.cpp b/src/plugins/ios/iosrunner.cpp
index 868e2bb34f0..2b9e3645803 100644
--- a/src/plugins/ios/iosrunner.cpp
+++ b/src/plugins/ios/iosrunner.cpp
@@ -50,7 +50,7 @@ IosRunner::IosRunner(QObject *parent, IosRunConfiguration *runConfig, bool debug
     : QObject(parent), m_toolHandler(0), m_bundleDir(runConfig->bundleDir().toString()),
       m_arguments(runConfig->commandLineArguments()),
       m_device(ProjectExplorer::DeviceKitInformation::device(runConfig->target()->kit())),
-      m_debuggingMode(debuggingMode), m_cleanExit(false), m_didWarn(false)
+      m_debuggingMode(debuggingMode), m_cleanExit(false)
 {
 }
 
@@ -157,9 +157,6 @@ void IosRunner::handleAppOutput(IosToolHandler *handler, const QString &output)
 
 void IosRunner::warnAboutRunFail()
 {
-    if (m_didWarn)
-        return;
-    m_didWarn = true;
     QMessageBox mBox;
     mBox.setText(tr("Running on iOS device failed."));
     mBox.setInformativeText(tr("The certificates in Xcode or the device might be outdated. Check the certificates in the organizer window of Xcode, and try again."));
@@ -169,11 +166,24 @@ void IosRunner::warnAboutRunFail()
     mBox.exec();
 }
 
+void IosRunner::warnAboutDeployFail()
+{
+    QMessageBox mBox;
+    mBox.setText(tr("Deploying to iOS device failed."));
+    mBox.setInformativeText(tr("This might be due to an incorrect Info.plist or outdated certificates in Xcode or device (see organizer window of Xcode)."));
+    mBox.setStandardButtons(QMessageBox::Ok);
+    mBox.setDefaultButton(QMessageBox::Ok);
+    mBox.setIcon(QMessageBox::Information);
+    mBox.exec();
+}
+
 void IosRunner::handleErrorMsg(IosToolHandler *handler, const QString &msg)
 {
     Q_UNUSED(handler);
     if (msg.contains(QLatin1String("AMDeviceStartService returned -402653150")))
         QTimer::singleShot(0, this, SLOT(warnAboutRunFail()));
+    else if (msg.contains(QLatin1String("AMDeviceInstallApplication returned -402653103")))
+        QTimer::singleShot(0, this, SLOT(warnAboutDeployFail()));
     emit errorMsg(msg);
 }
 
diff --git a/src/plugins/ios/iosrunner.h b/src/plugins/ios/iosrunner.h
index 99b6f8d804d..c5042e10e0d 100644
--- a/src/plugins/ios/iosrunner.h
+++ b/src/plugins/ios/iosrunner.h
@@ -71,6 +71,7 @@ signals:
     void finished(bool cleanExit);
 private slots:
     void warnAboutRunFail();
+    void warnAboutDeployFail();
     void handleDidStartApp(Ios::IosToolHandler *handler, const QString &bundlePath,
                            const QString &deviceId, Ios::IosToolHandler::OpStatus status);
     void handleGotGdbserverSocket(Ios::IosToolHandler *handler, const QString &bundlePath,
@@ -88,7 +89,6 @@ private:
     ProjectExplorer::IDevice::ConstPtr m_device;
     bool m_debuggingMode;
     bool m_cleanExit;
-    bool m_didWarn;
 };
 
 } // namespace Internal
-- 
GitLab