Xcode: Generate scheme manually, instead of letting Xcode do it

A scheme is required to be able to run tests through Xcode, even from the
command line, but Xcode doesn't auto-generate the schemes until launched
as an application. Xcode also auto-generates schemes for all our targets,
but we only need one for the primary application target.

Change-Id: Ia42f3825aba3ffde3be93be55e165d6284434853
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@theqtcompany.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
This commit is contained in:
Tor Arne Vestbø 2015-02-09 15:01:30 +01:00 committed by Tor Arne Vestbø
parent 91828af6c5
commit 08f6af608a
4 changed files with 152 additions and 0 deletions

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key>
<false/>
</dict>
</plist>

View File

@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0610"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "@TARGET_PBX_KEY@"
BuildableName = "@QMAKE_ORIG_TARGET@"
BlueprintName = "@QMAKE_ORIG_TARGET@"
ReferencedContainer = "container:@QMAKE_ORIG_TARGET@.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "@TARGET_PBX_KEY@"
BuildableName = "@QMAKE_ORIG_TARGET@"
BlueprintName = "@QMAKE_ORIG_TARGET@"
ReferencedContainer = "container:@QMAKE_ORIG_TARGET@.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "@TARGET_PBX_KEY@"
BuildableName = "@QMAKE_ORIG_TARGET@"
BlueprintName = "@QMAKE_ORIG_TARGET@"
ReferencedContainer = "container:@QMAKE_ORIG_TARGET@.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "@TARGET_PBX_KEY@"
BuildableName = "@QMAKE_ORIG_TARGET@"
BlueprintName = "@QMAKE_ORIG_TARGET@"
ReferencedContainer = "container:@QMAKE_ORIG_TARGET@.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "@TARGET_PBX_KEY@"
BuildableName = "@QMAKE_ORIG_TARGET@"
BlueprintName = "@QMAKE_ORIG_TARGET@"
ReferencedContainer = "container:@QMAKE_ORIG_TARGET@.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -6,6 +6,8 @@
QMAKESPEC = $$dirname(PWD)/$$[QMAKE_XSPEC]
QMAKE_XCODE_SPECDIR = $$PWD
include($$QMAKESPEC/qmake.conf)
MAKEFILE_GENERATOR = XCODE

View File

@ -1573,6 +1573,52 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
}
}
// Scheme
{
QString xcodeSpecDir = project->first("QMAKE_XCODE_SPECDIR").toQString();
bool wroteCustomScheme = false;
QString projectSharedSchemesPath = pbx_dir + "/xcshareddata/xcschemes";
if (mkdir(projectSharedSchemesPath)) {
QString target = project->first("QMAKE_ORIG_TARGET").toQString();
QFile defaultSchemeFile(xcodeSpecDir + "/default.xcscheme");
QFile outputSchemeFile(projectSharedSchemesPath + Option::dir_sep + target + ".xcscheme");
if (defaultSchemeFile.open(QIODevice::ReadOnly)
&& outputSchemeFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
QTextStream defaultSchemeStream(&defaultSchemeFile);
QString schemeData = defaultSchemeStream.readAll();
schemeData.replace("@QMAKE_ORIG_TARGET@", target);
schemeData.replace("@TARGET_PBX_KEY@", keyFor(pbx_dir + "QMAKE_PBX_TARGET"));
QTextStream outputSchemeStream(&outputSchemeFile);
outputSchemeStream << schemeData;
wroteCustomScheme = true;
}
}
if (wroteCustomScheme) {
// Prevent Xcode from auto-generating schemes
QString workspaceSettingsFilename("WorkspaceSettings.xcsettings");
QString workspaceSharedDataPath = pbx_dir + "/project.xcworkspace/xcshareddata";
if (mkdir(workspaceSharedDataPath)) {
QFile::copy(xcodeSpecDir + Option::dir_sep + workspaceSettingsFilename,
workspaceSharedDataPath + Option::dir_sep + workspaceSettingsFilename);
} else {
wroteCustomScheme = false;
}
}
if (!wroteCustomScheme)
warn_msg(WarnLogic, "Failed to generate schemes in '%s', " \
"falling back to Xcode auto-generated schemes", qPrintable(projectSharedSchemesPath));
}
qmake_setpwd(input_dir);
return true;