2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2013-04-25 16:02:17 +02:00
|
|
|
|
|
|
|
#include "iosrunconfiguration.h"
|
2022-12-20 13:39:23 +01:00
|
|
|
|
2014-07-07 09:24:17 +02:00
|
|
|
#include "iosconstants.h"
|
2018-09-19 09:12:21 +02:00
|
|
|
#include "iosdevice.h"
|
2022-12-20 13:39:23 +01:00
|
|
|
#include "iostr.h"
|
2016-09-26 12:40:09 +02:00
|
|
|
#include "simulatorcontrol.h"
|
2013-04-25 16:02:17 +02:00
|
|
|
|
2018-05-07 13:24:13 +02:00
|
|
|
#include <projectexplorer/buildconfiguration.h>
|
2013-04-25 16:02:17 +02:00
|
|
|
#include <projectexplorer/buildstep.h>
|
|
|
|
#include <projectexplorer/buildsteplist.h>
|
2018-05-07 13:24:13 +02:00
|
|
|
#include <projectexplorer/deployconfiguration.h>
|
|
|
|
#include <projectexplorer/devicesupport/devicemanager.h>
|
2023-08-11 09:18:56 +02:00
|
|
|
#include <projectexplorer/kitaspects.h>
|
2019-04-29 18:27:53 +02:00
|
|
|
#include <projectexplorer/project.h>
|
2024-01-15 15:38:18 +01:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2019-04-29 18:27:53 +02:00
|
|
|
#include <projectexplorer/projectnodes.h>
|
2016-01-05 17:13:35 +01:00
|
|
|
#include <projectexplorer/runconfigurationaspects.h>
|
2018-05-07 13:24:13 +02:00
|
|
|
#include <projectexplorer/target.h>
|
2018-04-25 10:26:08 +02:00
|
|
|
|
2017-01-24 16:30:26 +01:00
|
|
|
#include <utils/algorithm.h>
|
2022-12-20 13:39:23 +01:00
|
|
|
#include <utils/filepath.h>
|
2020-09-18 12:11:40 +02:00
|
|
|
#include <utils/layoutbuilder.h>
|
2023-05-03 17:05:35 +02:00
|
|
|
#include <utils/process.h>
|
|
|
|
#include <utils/qtcassert.h>
|
2015-01-10 23:40:32 +02:00
|
|
|
|
2015-12-18 15:51:23 +01:00
|
|
|
#include <QAction>
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QComboBox>
|
|
|
|
#include <QHeaderView>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QLineEdit>
|
2013-04-25 16:02:17 +02:00
|
|
|
#include <QList>
|
2015-12-18 15:51:23 +01:00
|
|
|
#include <QVariant>
|
|
|
|
#include <QWidget>
|
2013-04-25 16:02:17 +02:00
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
2014-02-05 10:43:21 +01:00
|
|
|
using namespace Utils;
|
2013-04-25 16:02:17 +02:00
|
|
|
|
2023-01-06 15:54:09 +01:00
|
|
|
namespace Ios::Internal {
|
2013-04-25 16:02:17 +02:00
|
|
|
|
2023-08-25 13:19:26 +02:00
|
|
|
const char deviceTypeKey[] = "Ios.device_type";
|
2014-01-16 18:35:36 +01:00
|
|
|
|
2019-08-09 11:09:27 +02:00
|
|
|
static QString displayName(const SimulatorInfo &device)
|
|
|
|
{
|
|
|
|
return QString("%1, %2").arg(device.name).arg(device.runtimeName);
|
|
|
|
}
|
|
|
|
|
2017-01-24 16:30:26 +01:00
|
|
|
static IosDeviceType toIosDeviceType(const SimulatorInfo &device)
|
|
|
|
{
|
|
|
|
IosDeviceType iosDeviceType(IosDeviceType::SimulatedDevice,
|
|
|
|
device.identifier,
|
2019-08-09 11:09:27 +02:00
|
|
|
displayName(device));
|
2017-01-24 16:30:26 +01:00
|
|
|
return iosDeviceType;
|
|
|
|
}
|
|
|
|
|
2022-05-11 13:54:42 +02:00
|
|
|
IosRunConfiguration::IosRunConfiguration(Target *target, Id id)
|
2023-07-14 12:31:52 +02:00
|
|
|
: RunConfiguration(target, id), iosDeviceType(this, this)
|
2013-04-25 16:02:17 +02:00
|
|
|
{
|
2023-07-14 12:31:52 +02:00
|
|
|
executable.setDeviceSelector(target, ExecutableAspect::RunDevice);
|
2018-09-07 12:56:34 +02:00
|
|
|
|
2023-07-14 12:31:52 +02:00
|
|
|
arguments.setMacroExpander(macroExpander());
|
2017-09-01 13:23:02 +02:00
|
|
|
|
2023-07-14 12:31:52 +02:00
|
|
|
setUpdater([this, target] {
|
2019-12-04 09:51:46 +01:00
|
|
|
IDevice::ConstPtr dev = DeviceKitAspect::device(target->kit());
|
|
|
|
const QString devName = dev.isNull() ? IosDevice::name() : dev->displayName();
|
2022-12-20 13:39:23 +01:00
|
|
|
setDefaultDisplayName(Tr::tr("Run on %1").arg(devName));
|
|
|
|
setDisplayName(Tr::tr("Run %1 on %2").arg(applicationName()).arg(devName));
|
2019-12-04 09:51:46 +01:00
|
|
|
|
2023-07-14 12:31:52 +02:00
|
|
|
executable.setExecutable(localExecutable());
|
|
|
|
iosDeviceType.updateDeviceType();
|
2019-12-04 09:51:46 +01:00
|
|
|
});
|
2013-04-25 16:02:17 +02:00
|
|
|
}
|
|
|
|
|
2018-09-19 09:01:01 +02:00
|
|
|
void IosDeviceTypeAspect::deviceChanges()
|
ProjectExplorer/all: Re-organize BuildSteps/{Deploy,Build}Config setup
This follow the rough pattern of recent *RunConfigurationFactory changes
for build and deploy configurations.
- Collapse the two lines of constructors similar to what
890c1906e6fb2ec did for RunConfigurations
* Deploy* was purely mechanical
* Build* ctors are split in connects() in the ctor body
to create "empty shell for clone" etc
and build step additions in initialize() functions which
are only used in the create() case.
-- Allows to collapse the shared 'ctor()' functions, too.
- Move FooBuildConfigurationFactory::create() implementations
to FooBuildConfiguration() constructor. That was a strange
and unneeded ping-pong between factories and objects, and
furthermore allows one level less of indirection (and for a
later, left out here, some reduction of the
FooBuildConfiguration interfaces that were only used to
accommodate the *Factory::create() functions.
- Most {Build,Deploy}Configuration{,Factory} classes had a canHandle(),
but there wasn't one in the base classses. Have one there.
- Most canHandle() functions were checking simple restrictions on
e.g. project or target types, specify those by setters in the
constructors instead and check them in the base canHandle()
- clone() is generally replaced by a creation of a "shell object"
and a fromMap(source->toMap()), implemented in the base, there
are two cases left for Android and Qbs that needed(?) some extra
polish
- generally use canHandle() in base implementation, instead
of doing that in all Derived::canFoo()
- as a result, canCreate/create/canClone/clone reimplementations
are not needed anymore, keep the base implementation for
now (could be inlined into their only users later), but
de-virtualize them.
- Combine Ios{Preset,DSym}BuildStepFactory. There was only one
'dsym' build step they could create.
- Split the 'mangled' id into the ProjectConfiguration subtype
specific constant identifier, and a QString extraId() bit.
Only maintain the mangled id in saved settings.
- Make ProjectConfiguration::m_id a constant member, adapt
all constructors of derived classe.
Not done in this patch:
- Finish possible cosmetic changes on top
- Add a way to specify restrictions to supported Qt versions
(used in Android/Ios), as the base implementation does not
depend on the qtsupport plugin
- Combine the QList<X> availableFoo() + createFoo(X) function
pairs to somthing like a direct
QList<struct { X; std::function<X()>; }> fooCreators()
to avoid e.g. the baseId.withSuffix() <-> id.suffixAfter(base)
pingpong
- Remove the *Factories from the global object pool
- Do something about priority(). Falling back to plain
qmake in android+qmake setup is not helpful.
Change-Id: I2be7d88d554c5aa8b7db8edf5b93278e1ae0112a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-11-29 12:28:40 +01:00
|
|
|
{
|
2019-12-04 09:19:50 +01:00
|
|
|
m_runConfiguration->update();
|
2013-04-25 16:02:17 +02:00
|
|
|
}
|
|
|
|
|
2018-09-19 09:01:01 +02:00
|
|
|
void IosDeviceTypeAspect::updateDeviceType()
|
2018-05-14 16:16:03 +02:00
|
|
|
{
|
2020-09-07 15:56:18 +02:00
|
|
|
if (DeviceTypeKitAspect::deviceTypeId(m_runConfiguration->kit())
|
2018-09-19 09:01:01 +02:00
|
|
|
== Constants::IOS_DEVICE_TYPE)
|
2018-05-14 16:16:03 +02:00
|
|
|
m_deviceType = IosDeviceType(IosDeviceType::IosDevice);
|
|
|
|
else if (m_deviceType.type == IosDeviceType::IosDevice)
|
|
|
|
m_deviceType = IosDeviceType(IosDeviceType::SimulatedDevice);
|
|
|
|
}
|
|
|
|
|
2024-01-15 15:38:18 +01:00
|
|
|
bool IosRunConfiguration::isEnabled(Id runMode) const
|
2017-07-17 14:34:05 +02:00
|
|
|
{
|
2020-09-07 15:56:18 +02:00
|
|
|
Utils::Id devType = DeviceTypeKitAspect::deviceTypeId(kit());
|
2019-10-25 09:55:32 +02:00
|
|
|
if (devType != Constants::IOS_DEVICE_TYPE && devType != Constants::IOS_SIMULATOR_TYPE)
|
|
|
|
return false;
|
2024-01-19 10:49:16 +01:00
|
|
|
if (devType == Constants::IOS_SIMULATOR_TYPE)
|
|
|
|
return true;
|
2019-10-25 09:55:32 +02:00
|
|
|
|
2020-09-07 15:56:18 +02:00
|
|
|
IDevice::ConstPtr dev = DeviceKitAspect::device(kit());
|
2019-10-25 09:55:32 +02:00
|
|
|
if (dev.isNull() || dev->deviceState() != IDevice::DeviceReadyToUse)
|
|
|
|
return false;
|
|
|
|
|
2024-01-15 15:38:18 +01:00
|
|
|
IosDevice::ConstPtr iosdevice = dev.dynamicCast<const IosDevice>();
|
|
|
|
if (iosdevice && iosdevice->handler() == IosDevice::Handler::DeviceCtl
|
|
|
|
&& runMode != ProjectExplorer::Constants::NORMAL_RUN_MODE) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
return true;
|
2017-07-17 14:34:05 +02:00
|
|
|
}
|
|
|
|
|
2014-04-10 11:35:36 +02:00
|
|
|
QString IosRunConfiguration::applicationName() const
|
2013-04-25 16:02:17 +02:00
|
|
|
{
|
2020-09-07 15:56:18 +02:00
|
|
|
if (ProjectNode *node = project()->findNodeForBuildKey(buildKey()))
|
2019-04-29 18:27:53 +02:00
|
|
|
return node->data(Constants::IosTarget).toString();
|
|
|
|
|
2013-04-25 16:02:17 +02:00
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
2019-05-28 13:49:26 +02:00
|
|
|
FilePath IosRunConfiguration::bundleDirectory() const
|
2013-04-25 16:02:17 +02:00
|
|
|
{
|
2020-09-07 15:56:18 +02:00
|
|
|
Utils::Id devType = DeviceTypeKitAspect::deviceTypeId(kit());
|
2013-04-25 16:02:17 +02:00
|
|
|
bool isDevice = (devType == Constants::IOS_DEVICE_TYPE);
|
|
|
|
if (!isDevice && devType != Constants::IOS_SIMULATOR_TYPE) {
|
2014-07-07 09:24:17 +02:00
|
|
|
qCWarning(iosLog) << "unexpected device type in bundleDirForTarget: " << devType.toString();
|
2019-05-15 15:49:19 +02:00
|
|
|
return {};
|
2013-04-25 16:02:17 +02:00
|
|
|
}
|
2019-05-28 13:49:26 +02:00
|
|
|
FilePath res;
|
2021-09-08 02:40:38 +03:00
|
|
|
bool shouldAppendBuildTypeAndPlatform = true;
|
2018-05-07 13:24:13 +02:00
|
|
|
if (BuildConfiguration *bc = target()->activeBuildConfiguration()) {
|
2018-11-28 18:52:19 +01:00
|
|
|
Project *project = target()->project();
|
2021-09-08 02:40:38 +03:00
|
|
|
if (ProjectNode *node = project->findNodeForBuildKey(buildKey())) {
|
|
|
|
QString pathStr = node->data(Constants::IosBuildDir).toString();
|
|
|
|
const QString cmakeGenerator = node->data(Constants::IosCmakeGenerator).toString();
|
|
|
|
|
|
|
|
if (cmakeGenerator.isEmpty()) {
|
|
|
|
// qmake node gives absolute IosBuildDir
|
|
|
|
res = FilePath::fromString(pathStr);
|
|
|
|
} else {
|
|
|
|
// CMake node gives IosBuildDir relative to root build directory
|
|
|
|
|
|
|
|
bool useCmakePath = true;
|
|
|
|
|
|
|
|
if (pathStr.isEmpty())
|
|
|
|
useCmakePath = false;
|
|
|
|
|
|
|
|
if (useCmakePath && cmakeGenerator == "Xcode") {
|
|
|
|
// When generating Xcode project, CMake may put a "${EFFECTIVE_PLATFORM_NAME}" macro,
|
|
|
|
// which is expanded by Xcode at build time.
|
|
|
|
// To get an actual executable path at configure time, replace this macro here
|
|
|
|
// depending on the device type.
|
|
|
|
|
|
|
|
const QString before = "${EFFECTIVE_PLATFORM_NAME}";
|
|
|
|
|
|
|
|
int idx = pathStr.indexOf(before);
|
|
|
|
|
|
|
|
if (idx == -1) {
|
|
|
|
useCmakePath = false;
|
|
|
|
} else {
|
|
|
|
QString after;
|
|
|
|
if (isDevice)
|
|
|
|
after = "-iphoneos";
|
|
|
|
else
|
|
|
|
after = "-iphonesimulator";
|
|
|
|
|
|
|
|
pathStr.replace(idx, before.length(), after);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (useCmakePath) {
|
|
|
|
// With Ninja generator IosBuildDir may be just "." when executable is in the root directory,
|
|
|
|
// so use canonical path to ensure that redundand dot is removed.
|
|
|
|
res = bc->buildDirectory().pathAppended(pathStr).canonicalPath();
|
|
|
|
// All done with path provided by CMake
|
|
|
|
shouldAppendBuildTypeAndPlatform = false;
|
|
|
|
} else {
|
|
|
|
res = bc->buildDirectory();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (res.isEmpty()) {
|
|
|
|
// Fallback
|
2014-03-10 16:30:32 +01:00
|
|
|
res = bc->buildDirectory();
|
2021-09-08 02:40:38 +03:00
|
|
|
shouldAppendBuildTypeAndPlatform = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (shouldAppendBuildTypeAndPlatform) {
|
|
|
|
switch (bc->buildType()) {
|
|
|
|
case BuildConfiguration::Debug :
|
|
|
|
case BuildConfiguration::Unknown :
|
|
|
|
if (isDevice)
|
|
|
|
res = res / "Debug-iphoneos";
|
|
|
|
else
|
|
|
|
res = res.pathAppended("Debug-iphonesimulator");
|
|
|
|
break;
|
|
|
|
case BuildConfiguration::Profile :
|
|
|
|
case BuildConfiguration::Release :
|
|
|
|
if (isDevice)
|
|
|
|
res = res.pathAppended("Release-iphoneos");
|
|
|
|
else
|
|
|
|
res = res.pathAppended("Release-iphonesimulator");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
qCWarning(iosLog) << "IosBuildStep had an unknown buildType "
|
|
|
|
<< target()->activeBuildConfiguration()->buildType();
|
|
|
|
}
|
2013-04-25 16:02:17 +02:00
|
|
|
}
|
|
|
|
}
|
2019-05-15 15:49:19 +02:00
|
|
|
return res.pathAppended(applicationName() + ".app");
|
2013-04-25 16:02:17 +02:00
|
|
|
}
|
|
|
|
|
2019-05-28 13:49:26 +02:00
|
|
|
FilePath IosRunConfiguration::localExecutable() const
|
2013-04-25 16:02:17 +02:00
|
|
|
{
|
2019-05-15 15:49:19 +02:00
|
|
|
return bundleDirectory().pathAppended(applicationName());
|
2013-04-25 16:02:17 +02:00
|
|
|
}
|
|
|
|
|
2023-08-23 16:53:06 +02:00
|
|
|
void IosDeviceTypeAspect::fromMap(const Store &map)
|
2014-01-16 18:35:36 +01:00
|
|
|
{
|
2014-11-12 19:41:59 +01:00
|
|
|
bool deviceTypeIsInt;
|
|
|
|
map.value(deviceTypeKey).toInt(&deviceTypeIsInt);
|
2023-08-28 10:55:31 +02:00
|
|
|
if (deviceTypeIsInt || !m_deviceType.fromMap(storeFromVariant(map.value(deviceTypeKey))))
|
2018-05-14 16:16:03 +02:00
|
|
|
updateDeviceType();
|
ProjectExplorer/all: Re-organize BuildSteps/{Deploy,Build}Config setup
This follow the rough pattern of recent *RunConfigurationFactory changes
for build and deploy configurations.
- Collapse the two lines of constructors similar to what
890c1906e6fb2ec did for RunConfigurations
* Deploy* was purely mechanical
* Build* ctors are split in connects() in the ctor body
to create "empty shell for clone" etc
and build step additions in initialize() functions which
are only used in the create() case.
-- Allows to collapse the shared 'ctor()' functions, too.
- Move FooBuildConfigurationFactory::create() implementations
to FooBuildConfiguration() constructor. That was a strange
and unneeded ping-pong between factories and objects, and
furthermore allows one level less of indirection (and for a
later, left out here, some reduction of the
FooBuildConfiguration interfaces that were only used to
accommodate the *Factory::create() functions.
- Most {Build,Deploy}Configuration{,Factory} classes had a canHandle(),
but there wasn't one in the base classses. Have one there.
- Most canHandle() functions were checking simple restrictions on
e.g. project or target types, specify those by setters in the
constructors instead and check them in the base canHandle()
- clone() is generally replaced by a creation of a "shell object"
and a fromMap(source->toMap()), implemented in the base, there
are two cases left for Android and Qbs that needed(?) some extra
polish
- generally use canHandle() in base implementation, instead
of doing that in all Derived::canFoo()
- as a result, canCreate/create/canClone/clone reimplementations
are not needed anymore, keep the base implementation for
now (could be inlined into their only users later), but
de-virtualize them.
- Combine Ios{Preset,DSym}BuildStepFactory. There was only one
'dsym' build step they could create.
- Split the 'mangled' id into the ProjectConfiguration subtype
specific constant identifier, and a QString extraId() bit.
Only maintain the mangled id in saved settings.
- Make ProjectConfiguration::m_id a constant member, adapt
all constructors of derived classe.
Not done in this patch:
- Finish possible cosmetic changes on top
- Add a way to specify restrictions to supported Qt versions
(used in Android/Ios), as the base implementation does not
depend on the qtsupport plugin
- Combine the QList<X> availableFoo() + createFoo(X) function
pairs to somthing like a direct
QList<struct { X; std::function<X()>; }> fooCreators()
to avoid e.g. the baseId.withSuffix() <-> id.suffixAfter(base)
pingpong
- Remove the *Factories from the global object pool
- Do something about priority(). Falling back to plain
qmake in android+qmake setup is not helpful.
Change-Id: I2be7d88d554c5aa8b7db8edf5b93278e1ae0112a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-11-29 12:28:40 +01:00
|
|
|
|
2019-12-04 09:51:46 +01:00
|
|
|
m_runConfiguration->update();
|
2014-01-16 18:35:36 +01:00
|
|
|
}
|
|
|
|
|
2023-08-23 16:53:06 +02:00
|
|
|
void IosDeviceTypeAspect::toMap(Store &map) const
|
2014-01-16 18:35:36 +01:00
|
|
|
{
|
2023-08-25 13:19:26 +02:00
|
|
|
map.insert(deviceTypeKey, QVariant::fromValue(deviceType().toMap()));
|
2014-01-16 18:35:36 +01:00
|
|
|
}
|
|
|
|
|
2024-01-15 15:38:18 +01:00
|
|
|
QString IosRunConfiguration::disabledReason(Id runMode) const
|
2014-02-14 01:02:30 +01:00
|
|
|
{
|
2020-09-07 15:56:18 +02:00
|
|
|
Utils::Id devType = DeviceTypeKitAspect::deviceTypeId(kit());
|
2014-02-14 01:02:30 +01:00
|
|
|
if (devType != Constants::IOS_DEVICE_TYPE && devType != Constants::IOS_SIMULATOR_TYPE)
|
2022-12-20 13:39:23 +01:00
|
|
|
return Tr::tr("Kit has incorrect device type for running on iOS devices.");
|
2020-09-07 15:56:18 +02:00
|
|
|
IDevice::ConstPtr dev = DeviceKitAspect::device(kit());
|
2014-02-14 01:02:30 +01:00
|
|
|
QString validDevName;
|
|
|
|
bool hasConncetedDev = false;
|
|
|
|
if (devType == Constants::IOS_DEVICE_TYPE) {
|
|
|
|
DeviceManager *dm = DeviceManager::instance();
|
|
|
|
for (int idev = 0; idev < dm->deviceCount(); ++idev) {
|
|
|
|
IDevice::ConstPtr availDev = dm->deviceAt(idev);
|
|
|
|
if (!availDev.isNull() && availDev->type() == Constants::IOS_DEVICE_TYPE) {
|
|
|
|
if (availDev->deviceState() == IDevice::DeviceReadyToUse) {
|
2014-08-29 14:00:18 +02:00
|
|
|
validDevName += QLatin1Char(' ');
|
2014-02-14 01:02:30 +01:00
|
|
|
validDevName += availDev->displayName();
|
|
|
|
} else if (availDev->deviceState() == IDevice::DeviceConnected) {
|
|
|
|
hasConncetedDev = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dev.isNull()) {
|
|
|
|
if (!validDevName.isEmpty())
|
2022-12-20 13:39:23 +01:00
|
|
|
return Tr::tr("No device chosen. Select %1.").arg(validDevName); // should not happen
|
2014-02-14 01:02:30 +01:00
|
|
|
else if (hasConncetedDev)
|
2022-12-20 13:39:23 +01:00
|
|
|
return Tr::tr("No device chosen. Enable developer mode on a device."); // should not happen
|
2014-02-14 01:02:30 +01:00
|
|
|
else
|
2022-12-20 13:39:23 +01:00
|
|
|
return Tr::tr("No device available.");
|
2024-01-19 10:49:16 +01:00
|
|
|
} else if (devType == Constants::IOS_DEVICE_TYPE) {
|
2014-02-14 01:02:30 +01:00
|
|
|
switch (dev->deviceState()) {
|
|
|
|
case IDevice::DeviceReadyToUse:
|
|
|
|
break;
|
|
|
|
case IDevice::DeviceConnected:
|
2022-12-20 13:39:23 +01:00
|
|
|
return Tr::tr("To use this device you need to enable developer mode on it.");
|
2014-02-14 01:02:30 +01:00
|
|
|
case IDevice::DeviceDisconnected:
|
|
|
|
case IDevice::DeviceStateUnknown:
|
|
|
|
if (!validDevName.isEmpty())
|
2022-12-20 13:39:23 +01:00
|
|
|
return Tr::tr("%1 is not connected. Select %2?")
|
2014-02-14 01:02:30 +01:00
|
|
|
.arg(dev->displayName(), validDevName);
|
|
|
|
else if (hasConncetedDev)
|
2022-12-20 13:39:23 +01:00
|
|
|
return Tr::tr("%1 is not connected. Enable developer mode on a device?")
|
2014-02-14 01:02:30 +01:00
|
|
|
.arg(dev->displayName());
|
|
|
|
else
|
2022-12-20 13:39:23 +01:00
|
|
|
return Tr::tr("%1 is not connected.").arg(dev->displayName());
|
2014-02-14 01:02:30 +01:00
|
|
|
}
|
2024-01-15 15:38:18 +01:00
|
|
|
IosDevice::ConstPtr iosdevice = dev.dynamicCast<const IosDevice>();
|
|
|
|
if (iosdevice && iosdevice->handler() == IosDevice::Handler::DeviceCtl
|
|
|
|
&& runMode != ProjectExplorer::Constants::NORMAL_RUN_MODE) {
|
|
|
|
return Tr::tr("Debugging and profiling is currently not supported for devices with iOS "
|
|
|
|
"17 and later.");
|
|
|
|
}
|
2014-02-14 01:02:30 +01:00
|
|
|
}
|
2024-01-15 15:38:18 +01:00
|
|
|
return RunConfiguration::disabledReason(runMode);
|
2014-02-14 01:02:30 +01:00
|
|
|
}
|
|
|
|
|
2014-11-12 19:41:59 +01:00
|
|
|
IosDeviceType IosRunConfiguration::deviceType() const
|
2018-09-19 09:01:01 +02:00
|
|
|
{
|
2023-07-14 12:31:52 +02:00
|
|
|
return iosDeviceType.deviceType();
|
2018-09-19 09:01:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
IosDeviceType IosDeviceTypeAspect::deviceType() const
|
2014-03-28 19:05:35 +01:00
|
|
|
{
|
2017-01-24 16:30:26 +01:00
|
|
|
if (m_deviceType.type == IosDeviceType::SimulatedDevice) {
|
|
|
|
QList<SimulatorInfo> availableSimulators = SimulatorControl::availableSimulators();
|
|
|
|
if (availableSimulators.isEmpty())
|
|
|
|
return m_deviceType;
|
|
|
|
if (Utils::contains(availableSimulators,
|
|
|
|
Utils::equal(&SimulatorInfo::identifier, m_deviceType.identifier))) {
|
|
|
|
return m_deviceType;
|
2014-11-12 19:41:59 +01:00
|
|
|
}
|
2017-01-24 16:30:26 +01:00
|
|
|
const QStringList parts = m_deviceType.displayName.split(QLatin1Char(','));
|
|
|
|
if (parts.count() < 2)
|
|
|
|
return toIosDeviceType(availableSimulators.last());
|
|
|
|
|
|
|
|
QList<SimulatorInfo> eligibleDevices;
|
|
|
|
eligibleDevices = Utils::filtered(availableSimulators, [parts](const SimulatorInfo &info) {
|
|
|
|
return info.name == parts.at(0) && info.runtimeName == parts.at(1);
|
|
|
|
});
|
|
|
|
return toIosDeviceType(eligibleDevices.isEmpty() ? availableSimulators.last()
|
|
|
|
: eligibleDevices.last());
|
2014-11-12 19:41:59 +01:00
|
|
|
}
|
2014-03-28 19:05:35 +01:00
|
|
|
return m_deviceType;
|
|
|
|
}
|
|
|
|
|
2018-09-19 09:01:01 +02:00
|
|
|
void IosDeviceTypeAspect::setDeviceType(const IosDeviceType &deviceType)
|
2014-03-28 19:05:35 +01:00
|
|
|
{
|
|
|
|
m_deviceType = deviceType;
|
|
|
|
}
|
|
|
|
|
2023-07-14 12:31:52 +02:00
|
|
|
IosDeviceTypeAspect::IosDeviceTypeAspect(AspectContainer *container, IosRunConfiguration *rc)
|
|
|
|
: BaseAspect(container), m_runConfiguration(rc)
|
2013-04-25 16:02:17 +02:00
|
|
|
{
|
2022-04-11 11:09:46 +02:00
|
|
|
addDataExtractor(this, &IosDeviceTypeAspect::deviceType, &Data::deviceType);
|
|
|
|
addDataExtractor(this, &IosDeviceTypeAspect::bundleDirectory, &Data::bundleDirectory);
|
|
|
|
addDataExtractor(this, &IosDeviceTypeAspect::applicationName, &Data::applicationName);
|
|
|
|
addDataExtractor(this, &IosDeviceTypeAspect::localExecutable, &Data::localExecutable);
|
|
|
|
|
2018-09-19 09:01:01 +02:00
|
|
|
connect(DeviceManager::instance(), &DeviceManager::updated,
|
|
|
|
this, &IosDeviceTypeAspect::deviceChanges);
|
|
|
|
connect(KitManager::instance(), &KitManager::kitsChanged,
|
|
|
|
this, &IosDeviceTypeAspect::deviceChanges);
|
|
|
|
}
|
2015-12-18 15:51:23 +01:00
|
|
|
|
2023-05-02 17:20:57 +02:00
|
|
|
void IosDeviceTypeAspect::addToLayout(Layouting::LayoutItem &parent)
|
2018-09-19 09:01:01 +02:00
|
|
|
{
|
2019-10-15 17:20:51 +02:00
|
|
|
m_deviceTypeComboBox = new QComboBox;
|
2015-12-18 15:51:23 +01:00
|
|
|
m_deviceTypeComboBox->setModel(&m_deviceTypeModel);
|
|
|
|
|
2022-12-20 13:39:23 +01:00
|
|
|
m_deviceTypeLabel = new QLabel(Tr::tr("Device type:"));
|
2015-12-18 15:51:23 +01:00
|
|
|
|
2023-05-02 17:20:57 +02:00
|
|
|
parent.addItems({m_deviceTypeLabel, m_deviceTypeComboBox});
|
2013-04-25 16:02:17 +02:00
|
|
|
|
|
|
|
updateValues();
|
|
|
|
|
2022-07-19 22:51:32 +02:00
|
|
|
connect(m_deviceTypeComboBox, &QComboBox::currentIndexChanged,
|
2018-09-19 09:01:01 +02:00
|
|
|
this, &IosDeviceTypeAspect::setDeviceTypeIndex);
|
2013-04-25 16:02:17 +02:00
|
|
|
}
|
|
|
|
|
2018-09-19 09:01:01 +02:00
|
|
|
void IosDeviceTypeAspect::setDeviceTypeIndex(int devIndex)
|
2014-03-28 19:05:35 +01:00
|
|
|
{
|
2014-11-12 19:41:59 +01:00
|
|
|
QVariant selectedDev = m_deviceTypeModel.data(m_deviceTypeModel.index(devIndex, 0), Qt::UserRole + 1);
|
|
|
|
if (selectedDev.isValid())
|
2018-09-19 09:01:01 +02:00
|
|
|
setDeviceType(toIosDeviceType(selectedDev.value<SimulatorInfo>()));
|
2014-03-28 19:05:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-09-19 09:01:01 +02:00
|
|
|
void IosDeviceTypeAspect::updateValues()
|
2013-04-25 16:02:17 +02:00
|
|
|
{
|
2019-08-29 18:03:48 +02:00
|
|
|
bool showDeviceSelector = deviceType().type != IosDeviceType::IosDevice;
|
2015-12-18 15:51:23 +01:00
|
|
|
m_deviceTypeLabel->setVisible(showDeviceSelector);
|
|
|
|
m_deviceTypeComboBox->setVisible(showDeviceSelector);
|
2014-11-12 19:41:59 +01:00
|
|
|
if (showDeviceSelector && m_deviceTypeModel.rowCount() == 0) {
|
2022-05-31 16:21:46 +02:00
|
|
|
const QList<SimulatorInfo> devices = SimulatorControl::availableSimulators();
|
|
|
|
for (const SimulatorInfo &device : devices) {
|
2019-08-09 11:09:27 +02:00
|
|
|
QStandardItem *item = new QStandardItem(Internal::displayName(device));
|
2014-11-12 19:41:59 +01:00
|
|
|
QVariant v;
|
2017-01-24 16:30:26 +01:00
|
|
|
v.setValue(device);
|
2014-11-12 19:41:59 +01:00
|
|
|
item->setData(v);
|
|
|
|
m_deviceTypeModel.appendRow(item);
|
|
|
|
}
|
|
|
|
}
|
2014-03-28 19:05:35 +01:00
|
|
|
|
2019-08-29 18:03:48 +02:00
|
|
|
IosDeviceType currentDType = deviceType();
|
2017-01-24 16:30:26 +01:00
|
|
|
QVariant currentData = m_deviceTypeComboBox->currentData();
|
2014-12-01 11:44:14 +01:00
|
|
|
if (currentDType.type == IosDeviceType::SimulatedDevice && !currentDType.identifier.isEmpty()
|
2017-01-24 16:30:26 +01:00
|
|
|
&& (!currentData.isValid()
|
|
|
|
|| currentDType != toIosDeviceType(currentData.value<SimulatorInfo>())))
|
2014-12-01 11:44:14 +01:00
|
|
|
{
|
2014-11-12 19:41:59 +01:00
|
|
|
bool didSet = false;
|
|
|
|
for (int i = 0; m_deviceTypeModel.hasIndex(i, 0); ++i) {
|
|
|
|
QVariant vData = m_deviceTypeModel.data(m_deviceTypeModel.index(i, 0), Qt::UserRole + 1);
|
2017-01-24 16:30:26 +01:00
|
|
|
SimulatorInfo dType = vData.value<SimulatorInfo>();
|
|
|
|
if (dType.identifier == currentDType.identifier) {
|
2015-12-18 15:51:23 +01:00
|
|
|
m_deviceTypeComboBox->setCurrentIndex(i);
|
2014-11-12 19:41:59 +01:00
|
|
|
didSet = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!didSet) {
|
|
|
|
qCWarning(iosLog) << "could not set " << currentDType << " as it is not in model";
|
|
|
|
}
|
|
|
|
}
|
2013-04-25 16:02:17 +02:00
|
|
|
}
|
|
|
|
|
2022-04-11 11:09:46 +02:00
|
|
|
FilePath IosDeviceTypeAspect::bundleDirectory() const
|
|
|
|
{
|
|
|
|
return m_runConfiguration->bundleDirectory();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString IosDeviceTypeAspect::applicationName() const
|
|
|
|
{
|
|
|
|
return m_runConfiguration->applicationName();
|
|
|
|
}
|
|
|
|
|
|
|
|
FilePath IosDeviceTypeAspect::localExecutable() const
|
|
|
|
{
|
|
|
|
return m_runConfiguration->localExecutable();
|
|
|
|
}
|
2018-04-25 10:26:08 +02:00
|
|
|
|
|
|
|
// IosRunConfigurationFactory
|
|
|
|
|
|
|
|
IosRunConfigurationFactory::IosRunConfigurationFactory()
|
|
|
|
{
|
2023-01-06 15:54:09 +01:00
|
|
|
registerRunConfiguration<IosRunConfiguration>(Constants::IOS_RUNCONFIG_ID);
|
2018-04-25 10:26:08 +02:00
|
|
|
addSupportedTargetDeviceType(Constants::IOS_DEVICE_TYPE);
|
|
|
|
addSupportedTargetDeviceType(Constants::IOS_SIMULATOR_TYPE);
|
|
|
|
}
|
|
|
|
|
2023-01-06 15:54:09 +01:00
|
|
|
} // Ios::Internal
|