forked from qt-creator/qt-creator
ios: warn if provisioning profile does not cover the targeted device
Task-number: QTCREATORBUG-12175 Change-Id: I58108bfca92add161ae3c1999954d073b30dba9c Reviewed-by: Eike Ziller <eike.ziller@digia.com> Reviewed-by: Tobias Hunger <tobias.hunger@digia.com> Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
This commit is contained in:
@@ -47,6 +47,9 @@
|
|||||||
#include <qtsupport/qtkitinformation.h>
|
#include <qtsupport/qtkitinformation.h>
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QTemporaryFile>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
#define ASSERT_STATE(state) ASSERT_STATE_GENERIC(State, state, m_state)
|
#define ASSERT_STATE(state) ASSERT_STATE_GENERIC(State, state, m_state)
|
||||||
|
|
||||||
@@ -60,6 +63,7 @@ const Core::Id IosDeployStep::Id("Qt4ProjectManager.IosDeployStep");
|
|||||||
|
|
||||||
IosDeployStep::IosDeployStep(ProjectExplorer::BuildStepList *parent)
|
IosDeployStep::IosDeployStep(ProjectExplorer::BuildStepList *parent)
|
||||||
: BuildStep(parent, Id)
|
: BuildStep(parent, Id)
|
||||||
|
, m_expectFail(false)
|
||||||
{
|
{
|
||||||
ctor();
|
ctor();
|
||||||
}
|
}
|
||||||
@@ -67,6 +71,7 @@ IosDeployStep::IosDeployStep(ProjectExplorer::BuildStepList *parent)
|
|||||||
IosDeployStep::IosDeployStep(ProjectExplorer::BuildStepList *parent,
|
IosDeployStep::IosDeployStep(ProjectExplorer::BuildStepList *parent,
|
||||||
IosDeployStep *other)
|
IosDeployStep *other)
|
||||||
: BuildStep(parent, other)
|
: BuildStep(parent, other)
|
||||||
|
, m_expectFail(false)
|
||||||
{
|
{
|
||||||
ctor();
|
ctor();
|
||||||
}
|
}
|
||||||
@@ -125,6 +130,7 @@ void IosDeployStep::run(QFutureInterface<bool> &fi)
|
|||||||
SLOT(handleFinished(Ios::IosToolHandler*)));
|
SLOT(handleFinished(Ios::IosToolHandler*)));
|
||||||
connect(m_toolHandler, SIGNAL(errorMsg(Ios::IosToolHandler*,QString)),
|
connect(m_toolHandler, SIGNAL(errorMsg(Ios::IosToolHandler*,QString)),
|
||||||
SLOT(handleErrorMsg(Ios::IosToolHandler*,QString)));
|
SLOT(handleErrorMsg(Ios::IosToolHandler*,QString)));
|
||||||
|
checkProvisioningProfile();
|
||||||
m_toolHandler->requestTransferApp(appBundle(), deviceId());
|
m_toolHandler->requestTransferApp(appBundle(), deviceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,6 +146,7 @@ void IosDeployStep::cleanup()
|
|||||||
m_transferStatus = NoTransfer;
|
m_transferStatus = NoTransfer;
|
||||||
m_device.clear();
|
m_device.clear();
|
||||||
m_toolHandler = 0;
|
m_toolHandler = 0;
|
||||||
|
m_expectFail = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IosDeployStep::handleIsTransferringApp(IosToolHandler *handler, const QString &bundlePath,
|
void IosDeployStep::handleIsTransferringApp(IosToolHandler *handler, const QString &bundlePath,
|
||||||
@@ -161,6 +168,7 @@ void IosDeployStep::handleDidTransferApp(IosToolHandler *handler, const QString
|
|||||||
m_transferStatus = TransferOk;
|
m_transferStatus = TransferOk;
|
||||||
} else {
|
} else {
|
||||||
m_transferStatus = TransferFailed;
|
m_transferStatus = TransferFailed;
|
||||||
|
if (!m_expectFail)
|
||||||
TaskHub::addTask(Task::Error,
|
TaskHub::addTask(Task::Error,
|
||||||
tr("Deployment failed. The settings in the Organizer window of Xcode might be incorrect."),
|
tr("Deployment failed. The settings in the Organizer window of Xcode might be incorrect."),
|
||||||
ProjectExplorer::Constants::TASK_CATEGORY_DEPLOYMENT);
|
ProjectExplorer::Constants::TASK_CATEGORY_DEPLOYMENT);
|
||||||
@@ -237,6 +245,59 @@ void IosDeployStep::writeOutput(const QString &text, OutputFormat format)
|
|||||||
emit addOutput(text, format);
|
emit addOutput(text, format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IosDeployStep::checkProvisioningProfile()
|
||||||
|
{
|
||||||
|
IosDevice::ConstPtr device = iosdevice();
|
||||||
|
if (device.isNull())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Utils::FileName provisioningFilePath = Utils::FileName::fromString(appBundle());
|
||||||
|
provisioningFilePath.appendPath(QLatin1String("embedded.mobileprovision"));
|
||||||
|
|
||||||
|
// the file is a signed plist stored in DER format
|
||||||
|
// we simply search for start and end of the plist instead of decoding the DER payload
|
||||||
|
if (!provisioningFilePath.toFileInfo().exists())
|
||||||
|
return;
|
||||||
|
QFile provisionFile(provisioningFilePath.toString());
|
||||||
|
if (!provisionFile.open(QIODevice::ReadOnly))
|
||||||
|
return;
|
||||||
|
QByteArray provisionData = provisionFile.readAll();
|
||||||
|
int start = provisionData.indexOf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
|
||||||
|
int end = provisionData.indexOf("</plist>");
|
||||||
|
if (start == -1 || end == -1)
|
||||||
|
return;
|
||||||
|
end += 8;
|
||||||
|
|
||||||
|
QTemporaryFile f;
|
||||||
|
if (!f.open())
|
||||||
|
return;
|
||||||
|
f.write(provisionData.mid(start, end - start));
|
||||||
|
f.flush();
|
||||||
|
QSettings provisionPlist(f.fileName(), QSettings::NativeFormat);
|
||||||
|
|
||||||
|
if (!provisionPlist.contains(QLatin1String("ProvisionedDevices")))
|
||||||
|
return;
|
||||||
|
QStringList deviceIds = provisionPlist.value(QLatin1String("ProvisionedDevices")).toStringList();
|
||||||
|
QString targetId = device->uniqueDeviceID();
|
||||||
|
foreach (const QString &deviceId, deviceIds) {
|
||||||
|
if (deviceId == targetId)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_expectFail = true;
|
||||||
|
QString provisioningProfile = provisionPlist.value(QLatin1String("Name")).toString();
|
||||||
|
QString provisioningUid = provisionPlist.value(QLatin1String("UUID")).toString();
|
||||||
|
Task task(Task::Warning,
|
||||||
|
tr("The provisioning profile \"%1\" (%2) used to sign the application "
|
||||||
|
"does not cover the device %3 (%4). Deployment to it will fail.")
|
||||||
|
.arg(provisioningProfile, provisioningUid, device->displayName(),
|
||||||
|
targetId),
|
||||||
|
Utils::FileName(), /* filename */
|
||||||
|
-1, /* line */
|
||||||
|
ProjectExplorer::Constants::TASK_CATEGORY_COMPILE);
|
||||||
|
emit addTask(task);
|
||||||
|
}
|
||||||
|
|
||||||
IDevice::ConstPtr IosDeployStep::device() const
|
IDevice::ConstPtr IosDeployStep::device() const
|
||||||
{
|
{
|
||||||
return m_device;
|
return m_device;
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ private:
|
|||||||
QString appBundle() const;
|
QString appBundle() const;
|
||||||
void raiseError(const QString &error);
|
void raiseError(const QString &error);
|
||||||
void writeOutput(const QString &text, OutputFormat = MessageOutput);
|
void writeOutput(const QString &text, OutputFormat = MessageOutput);
|
||||||
|
void checkProvisioningProfile();
|
||||||
private:
|
private:
|
||||||
TransferStatus m_transferStatus;
|
TransferStatus m_transferStatus;
|
||||||
IosToolHandler *m_toolHandler;
|
IosToolHandler *m_toolHandler;
|
||||||
@@ -110,6 +111,7 @@ private:
|
|||||||
ProjectExplorer::IDevice::ConstPtr m_device;
|
ProjectExplorer::IDevice::ConstPtr m_device;
|
||||||
QString m_bundlePath;
|
QString m_bundlePath;
|
||||||
static const Core::Id Id;
|
static const Core::Id Id;
|
||||||
|
bool m_expectFail;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
Reference in New Issue
Block a user