forked from qt-creator/qt-creator
CMake: iOS: Enable automatic provisioning updates
By default xcodebuild does not try create / download a provisioning profile for a project if a valid one does not exist locally in ~/Library/MobileDevice/Provisioning Profiles, even if the Xcode CODE_SIGN_STYLE attribute is set to Automatic. Starting with Xcode 9, xcodebuild accepts a new -allowProvisioningUpdates option. When passed, xcodebuild will request a new provisioning profile from Apple's servers for the current project and use it during the build. The provisioning profile is only needed when building for a real device, not the simulator. When building an iOS project with qmake, the option is embedded in the wrapping Makefile generated by qmake, so Qt Creator can simply call make (which it does). For CMake, there is no wrapping Makefile, so we need to pass the new option explicitly as an additional build tool argument. There might be cases where automatic provisioning is not desired, which is why there is now a new checkbox in the CMake build step configuration widget. It's default value is 'enabled', to match qmake's behavior. As an implementation detail, isiOS had to be moved to a header file so it's accessible to both the build configuration and the build step. Fixes: QTCREATORBUG-26246 Change-Id: Ic80cd965ba095d0ff379e13ad2ffb8c298c9f7c4 Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -1035,13 +1035,6 @@ bool CMakeBuildSettingsWidget::eventFilter(QObject *target, QEvent *event)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool isIos(const Kit *k)
|
||||
{
|
||||
const Id deviceType = DeviceTypeKitAspect::deviceTypeId(k);
|
||||
return deviceType == Ios::Constants::IOS_DEVICE_TYPE
|
||||
|| deviceType == Ios::Constants::IOS_SIMULATOR_TYPE;
|
||||
}
|
||||
|
||||
static bool isWebAssembly(const Kit *k)
|
||||
{
|
||||
return DeviceTypeKitAspect::deviceTypeId(k) == WebAssembly::Constants::WEBASSEMBLY_DEVICE_TYPE;
|
||||
@@ -1090,7 +1083,7 @@ static CommandLine defaultInitialCMakeCommand(const Kit *k, const QString buildT
|
||||
}
|
||||
|
||||
// Cross-compilation settings:
|
||||
if (!isIos(k)) { // iOS handles this differently
|
||||
if (!CMakeBuildConfiguration::isIos(k)) { // iOS handles this differently
|
||||
const QString sysRoot = SysRootKitAspect::sysRoot(k).path();
|
||||
if (!sysRoot.isEmpty()) {
|
||||
cmd.addArg("-DCMAKE_SYSROOT:PATH=" + sysRoot);
|
||||
@@ -1235,7 +1228,7 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(Target *target, Id id)
|
||||
}
|
||||
|
||||
const IDevice::ConstPtr device = DeviceKitAspect::device(k);
|
||||
if (isIos(k)) {
|
||||
if (CMakeBuildConfiguration::isIos(k)) {
|
||||
QtSupport::QtVersion *qt = QtSupport::QtKitAspect::qtVersion(k);
|
||||
if (qt && qt->qtVersion().majorVersion >= 6) {
|
||||
// TODO it would be better if we could set
|
||||
@@ -1351,6 +1344,13 @@ FilePath CMakeBuildConfiguration::shadowBuildDirectory(const FilePath &projectFi
|
||||
return buildPath;
|
||||
}
|
||||
|
||||
bool CMakeBuildConfiguration::isIos(const Kit *k)
|
||||
{
|
||||
const Id deviceType = DeviceTypeKitAspect::deviceTypeId(k);
|
||||
return deviceType == Ios::Constants::IOS_DEVICE_TYPE
|
||||
|| deviceType == Ios::Constants::IOS_SIMULATOR_TYPE;
|
||||
}
|
||||
|
||||
void CMakeBuildConfiguration::buildTarget(const QString &buildTarget)
|
||||
{
|
||||
auto cmBs = qobject_cast<CMakeBuildStep *>(findOrDefault(
|
||||
|
@@ -54,6 +54,7 @@ public:
|
||||
static Utils::FilePath
|
||||
shadowBuildDirectory(const Utils::FilePath &projectFilePath, const ProjectExplorer::Kit *k,
|
||||
const QString &bcName, BuildConfiguration::BuildType buildType);
|
||||
static bool isIos(const ProjectExplorer::Kit *k);
|
||||
|
||||
// Context menu action:
|
||||
void buildTarget(const QString &buildTarget);
|
||||
|
@@ -61,6 +61,8 @@ namespace Internal {
|
||||
const char BUILD_TARGETS_KEY[] = "CMakeProjectManager.MakeStep.BuildTargets";
|
||||
const char CMAKE_ARGUMENTS_KEY[] = "CMakeProjectManager.MakeStep.CMakeArguments";
|
||||
const char TOOL_ARGUMENTS_KEY[] = "CMakeProjectManager.MakeStep.AdditionalArguments";
|
||||
const char IOS_AUTOMATIC_PROVISIONG_UPDATES_ARGUMENTS_KEY[] =
|
||||
"CMakeProjectManager.MakeStep.iOSAutomaticProvisioningUpdates";
|
||||
|
||||
// CmakeProgressParser
|
||||
|
||||
@@ -181,6 +183,19 @@ CMakeBuildStep::CMakeBuildStep(BuildStepList *bsl, Utils::Id id) :
|
||||
m_toolArguments->setLabelText(tr("Tool arguments:"));
|
||||
m_toolArguments->setDisplayStyle(StringAspect::LineEditDisplay);
|
||||
|
||||
Kit *kit = buildConfiguration()->kit();
|
||||
if (CMakeBuildConfiguration::isIos(kit)) {
|
||||
m_useiOSAutomaticProvisioningUpdates = addAspect<BoolAspect>();
|
||||
m_useiOSAutomaticProvisioningUpdates->setDefaultValue(true);
|
||||
m_useiOSAutomaticProvisioningUpdates->setSettingsKey(
|
||||
IOS_AUTOMATIC_PROVISIONG_UPDATES_ARGUMENTS_KEY);
|
||||
m_useiOSAutomaticProvisioningUpdates->setLabel(
|
||||
tr("Enable automatic provisioning updates:"));
|
||||
m_useiOSAutomaticProvisioningUpdates->setToolTip(
|
||||
tr("Tells xcodebuild to create and download a provisioning profile "
|
||||
"if a valid one does not exist."));
|
||||
}
|
||||
|
||||
m_buildTargetModel.setHeader({tr("Target")});
|
||||
|
||||
setBuildTargets({defaultBuildTarget()});
|
||||
@@ -413,9 +428,18 @@ CommandLine CMakeBuildStep::cmakeCommand() const
|
||||
if (!m_cmakeArguments->value().isEmpty())
|
||||
cmd.addArgs(m_cmakeArguments->value(), CommandLine::Raw);
|
||||
|
||||
bool toolArgumentsSpecified = false;
|
||||
if (!m_toolArguments->value().isEmpty()) {
|
||||
cmd.addArg("--");
|
||||
cmd.addArgs(m_toolArguments->value(), CommandLine::Raw);
|
||||
toolArgumentsSpecified = true;
|
||||
}
|
||||
|
||||
if (m_useiOSAutomaticProvisioningUpdates && m_useiOSAutomaticProvisioningUpdates->value()) {
|
||||
// Only add the double dash if it wasn't added before.
|
||||
if (!toolArgumentsSpecified)
|
||||
cmd.addArg("--");
|
||||
cmd.addArgs("-allowProvisioningUpdates", CommandLine::Raw);
|
||||
}
|
||||
|
||||
return cmd;
|
||||
@@ -473,6 +497,10 @@ QWidget *CMakeBuildStep::createConfigWidget()
|
||||
Layouting::Form builder;
|
||||
builder.addRow(m_cmakeArguments);
|
||||
builder.addRow(m_toolArguments);
|
||||
|
||||
if (m_useiOSAutomaticProvisioningUpdates)
|
||||
builder.addRow(m_useiOSAutomaticProvisioningUpdates);
|
||||
|
||||
builder.addRow({new QLabel(tr("Targets:")), frame});
|
||||
auto widget = builder.emerge();
|
||||
|
||||
@@ -481,6 +509,9 @@ QWidget *CMakeBuildStep::createConfigWidget()
|
||||
connect(m_cmakeArguments, &StringAspect::changed, this, updateDetails);
|
||||
connect(m_toolArguments, &StringAspect::changed, this, updateDetails);
|
||||
|
||||
if (m_useiOSAutomaticProvisioningUpdates)
|
||||
connect(m_useiOSAutomaticProvisioningUpdates, &BoolAspect::changed, this, updateDetails);
|
||||
|
||||
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::settingsChanged,
|
||||
this, updateDetails);
|
||||
|
||||
|
@@ -105,6 +105,7 @@ private:
|
||||
QStringList m_buildTargets; // Convention: Empty string member signifies "Current executable"
|
||||
Utils::StringAspect *m_cmakeArguments = nullptr;
|
||||
Utils::StringAspect *m_toolArguments = nullptr;
|
||||
Utils::BoolAspect *m_useiOSAutomaticProvisioningUpdates = nullptr;
|
||||
bool m_waiting = false;
|
||||
|
||||
QString m_allTarget = "all";
|
||||
|
Reference in New Issue
Block a user