forked from qt-creator/qt-creator
iOS: Find Xcode version
To enable/disable the version specific features Change-Id: Ia4cbe83f0aae366f517d8b46f322d8202dbbe3c8 Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Jake Petroules <jake.petroules@qt.io>
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
#include <coreplugin/icore.h>
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/synchronousprocess.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/kitinformation.h>
|
||||
#include <projectexplorer/devicesupport/devicemanager.h>
|
||||
@@ -48,6 +49,7 @@
|
||||
#include <qtsupport/qtversionmanager.h>
|
||||
#include <qtsupport/qtversionfactory.h>
|
||||
|
||||
#include <QDomDocument>
|
||||
#include <QFileInfo>
|
||||
#include <QHash>
|
||||
#include <QList>
|
||||
@@ -62,6 +64,7 @@ using namespace Debugger;
|
||||
|
||||
namespace {
|
||||
Q_LOGGING_CATEGORY(kitSetupLog, "qtc.ios.kitSetup")
|
||||
Q_LOGGING_CATEGORY(iosCommonLog, "qtc.ios.common")
|
||||
}
|
||||
|
||||
using ToolChainPair = std::pair<ClangToolChain *, ClangToolChain *>;
|
||||
@@ -207,6 +210,33 @@ static void setupKit(Kit *kit, Core::Id pDeviceType, const ToolChainPair& toolCh
|
||||
SysRootKitInformation::setSysRoot(kit, sdkPath);
|
||||
}
|
||||
|
||||
static QVersionNumber findXcodeVersion()
|
||||
{
|
||||
Utils::SynchronousProcess pkgUtilProcess;
|
||||
Utils::SynchronousProcessResponse resp =
|
||||
pkgUtilProcess.runBlocking("pkgutil", QStringList("--pkg-info-plist=com.apple.pkg.Xcode"));
|
||||
if (resp.result == Utils::SynchronousProcessResponse::Finished) {
|
||||
QDomDocument xcodeVersionDoc;
|
||||
if (xcodeVersionDoc.setContent(resp.allRawOutput())) {
|
||||
QDomNodeList nodes = xcodeVersionDoc.elementsByTagName(QStringLiteral("key"));
|
||||
for (int i = 0; i < nodes.count(); ++i) {
|
||||
QDomElement elem = nodes.at(i).toElement();
|
||||
if (elem.text().compare(QStringLiteral("pkg-version")) == 0) {
|
||||
QString versionStr = elem.nextSiblingElement().text();
|
||||
return QVersionNumber::fromString(versionStr);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
qCDebug(iosCommonLog) << "Error finding Xcode version. Cannot parse xml output from pkgutil.";
|
||||
}
|
||||
} else {
|
||||
qCDebug(iosCommonLog) << "Error finding Xcode version. pkgutil command failed.";
|
||||
}
|
||||
|
||||
qCDebug(iosCommonLog) << "Error finding Xcode version. Unknow error.";
|
||||
return QVersionNumber();
|
||||
}
|
||||
|
||||
void IosConfigurations::updateAutomaticKitList()
|
||||
{
|
||||
const QList<Platform> platforms = handledPlatforms();
|
||||
@@ -312,6 +342,11 @@ FileName IosConfigurations::developerPath()
|
||||
return m_instance->m_developerPath;
|
||||
}
|
||||
|
||||
QVersionNumber IosConfigurations::xcodeVersion()
|
||||
{
|
||||
return m_instance->m_xcodeVersion;
|
||||
}
|
||||
|
||||
void IosConfigurations::save()
|
||||
{
|
||||
QSettings *settings = Core::ICore::settings();
|
||||
@@ -358,6 +393,9 @@ void IosConfigurations::setDeveloperPath(const FileName &devPath)
|
||||
QTimer::singleShot(1000, IosDeviceManager::instance(),
|
||||
&IosDeviceManager::monitorAvailableDevices);
|
||||
m_instance->updateSimulators();
|
||||
|
||||
// Find xcode version.
|
||||
m_instance->m_xcodeVersion = findXcodeVersion();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -32,6 +32,7 @@
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QVersionNumber>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QSettings;
|
||||
@@ -60,6 +61,7 @@ public:
|
||||
static bool ignoreAllDevices();
|
||||
static void setIgnoreAllDevices(bool ignoreDevices);
|
||||
static Utils::FileName developerPath();
|
||||
static QVersionNumber xcodeVersion();
|
||||
static Utils::FileName lldbPath();
|
||||
static void updateAutomaticKitList();
|
||||
|
||||
@@ -71,6 +73,7 @@ private:
|
||||
static void setDeveloperPath(const Utils::FileName &devPath);
|
||||
|
||||
Utils::FileName m_developerPath;
|
||||
QVersionNumber m_xcodeVersion;
|
||||
bool m_ignoreAllDevices;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user