Browse Source

Projucer: add option to Xcode exporter to embed a framework in an app bundle.

tags/2021-05-28
Lukasz Kozakiewicz 7 years ago
parent
commit
70ad10155f
2 changed files with 94 additions and 4 deletions
  1. +92
    -4
      extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Xcode.h
  2. +2
    -0
      extras/Projucer/Source/Utility/Helpers/jucer_PresetIDs.h

+ 92
- 4
extras/Projucer/Source/ProjectSaving/jucer_ProjectExport_Xcode.h View File

@@ -62,6 +62,8 @@ public:
pListPrefixHeaderValue (settings, Ids::pListPrefixHeader, getUndoManager()), pListPrefixHeaderValue (settings, Ids::pListPrefixHeader, getUndoManager()),
pListPreprocessValue (settings, Ids::pListPreprocess, getUndoManager()), pListPreprocessValue (settings, Ids::pListPreprocess, getUndoManager()),
extraFrameworksValue (settings, Ids::extraFrameworks, getUndoManager()), extraFrameworksValue (settings, Ids::extraFrameworks, getUndoManager()),
extraCustomFrameworksValue (settings, Ids::extraCustomFrameworks, getUndoManager()),
embeddedFrameworksValue (settings, Ids::embeddedFrameworks, getUndoManager()),
postbuildCommandValue (settings, Ids::postbuildCommand, getUndoManager()), postbuildCommandValue (settings, Ids::postbuildCommand, getUndoManager()),
prebuildCommandValue (settings, Ids::prebuildCommand, getUndoManager()), prebuildCommandValue (settings, Ids::prebuildCommand, getUndoManager()),
duplicateAppExResourcesFolderValue (settings, Ids::duplicateAppExResourcesFolder, getUndoManager(), true), duplicateAppExResourcesFolderValue (settings, Ids::duplicateAppExResourcesFolder, getUndoManager(), true),
@@ -110,6 +112,8 @@ public:
bool isPListPreprocessEnabled() const { return pListPreprocessValue.get(); } bool isPListPreprocessEnabled() const { return pListPreprocessValue.get(); }
String getExtraFrameworksString() const { return extraFrameworksValue.get(); } String getExtraFrameworksString() const { return extraFrameworksValue.get(); }
String getExtraCustomFrameworksString() const { return extraCustomFrameworksValue.get(); }
String getEmbeddedFrameworksString() const { return embeddedFrameworksValue.get(); }
String getPostBuildScript() const { return postbuildCommandValue.get(); } String getPostBuildScript() const { return postbuildCommandValue.get(); }
String getPreBuildScript() const { return prebuildCommandValue.get(); } String getPreBuildScript() const { return prebuildCommandValue.get(); }
@@ -294,9 +298,16 @@ public:
props.add (new TextPropertyComponent (pListPrefixHeaderValue, "PList Prefix Header", 512, false), props.add (new TextPropertyComponent (pListPrefixHeaderValue, "PList Prefix Header", 512, false),
"Header file containing definitions used in plist file (see PList Preprocess)."); "Header file containing definitions used in plist file (see PList Preprocess).");
props.add (new TextPropertyComponent (extraFrameworksValue, "Extra Frameworks", 2048, false),
"A comma-separated list of extra frameworks that should be added to the build. "
"(Don't include the .framework extension in the name)");
props.add (new TextPropertyComponent (extraFrameworksValue, "Extra System Frameworks", 2048, false),
"A comma-separated list of extra system frameworks that should be added to the build. "
"(Don't include the .framework extension in the name)"
" The frameworks are expected to be located in /System/Library/Frameworks");
props.add (new TextPropertyComponent (extraCustomFrameworksValue, "Extra Custom Frameworks", 8192, false),
"Paths to custom frameworks that should be added to the build (one per line).");
props.add (new TextPropertyComponent (embeddedFrameworksValue, "Embedded Frameworks", 8192, true),
"Paths to frameworks to be embedded with the app (one per line).");
props.add (new TextPropertyComponent (prebuildCommandValue, "Pre-Build Shell Script", 32768, true), props.add (new TextPropertyComponent (prebuildCommandValue, "Pre-Build Shell Script", 32768, true),
"Some shell-script that will be run before a build starts."); "Some shell-script that will be run before a build starts.");
@@ -1076,6 +1087,9 @@ public:
{ {
s.set ("INSTALL_PATH", installPath.quoted()); s.set ("INSTALL_PATH", installPath.quoted());
if (! owner.getEmbeddedFrameworks().isEmpty())
s.set ("LD_RUNPATH_SEARCH_PATHS", "\"$(inherited) @executable_path/Frameworks\"");
if (xcodeCopyToProductInstallPathAfterBuild) if (xcodeCopyToProductInstallPathAfterBuild)
{ {
s.set ("DEPLOYMENT_LOCATION", "YES"); s.set ("DEPLOYMENT_LOCATION", "YES");
@@ -1718,7 +1732,7 @@ private:
const bool iOS; const bool iOS;
ValueWithDefault customPListValue, pListPrefixHeaderValue, pListPreprocessValue, extraFrameworksValue, postbuildCommandValue,
ValueWithDefault customPListValue, pListPrefixHeaderValue, pListPreprocessValue, extraFrameworksValue, extraCustomFrameworksValue, embeddedFrameworksValue, postbuildCommandValue,
prebuildCommandValue, duplicateAppExResourcesFolderValue, iosDeviceFamilyValue, iPhoneScreenOrientationValue, prebuildCommandValue, duplicateAppExResourcesFolderValue, iosDeviceFamilyValue, iPhoneScreenOrientationValue,
iPadScreenOrientationValue, customXcodeResourceFoldersValue, customXcassetsFolderValue, iPadScreenOrientationValue, customXcodeResourceFoldersValue, customXcassetsFolderValue,
microphonePermissionNeededValue, microphonePermissionsTextValue, cameraPermissionNeededValue, cameraPermissionTextValue, microphonePermissionNeededValue, microphonePermissionsTextValue, cameraPermissionNeededValue, cameraPermissionTextValue,
@@ -1747,6 +1761,8 @@ private:
prepareTargets(); prepareTargets();
addFrameworks(); addFrameworks();
addCustomFrameworks();
addEmbeddedFrameworks();
addCustomResourceFolders(); addCustomResourceFolders();
addPlistFileReferences(); addPlistFileReferences();
@@ -2397,6 +2413,49 @@ private:
} }
} }
void addCustomFrameworks() const
{
StringArray customFrameworks;
customFrameworks.addTokens (getExtraCustomFrameworksString(), true);
customFrameworks.trim();
for (auto& framework : customFrameworks)
{
auto frameworkID = addCustomFramework (framework);
for (auto& target : targets)
{
target->frameworkIDs.add (frameworkID);
target->frameworkNames.add (framework);
}
}
}
void addEmbeddedFrameworks() const
{
auto frameworks = getEmbeddedFrameworks();
if (frameworks.isEmpty())
return;
StringArray frameworkIDs;
for (auto& f : frameworks)
frameworkIDs.add (addEmbeddedFramework (f));
for (auto& target : targets)
target->addCopyFilesPhase ("Embed Frameworks", frameworkIDs, kFrameworksFolder);
}
StringArray getEmbeddedFrameworks() const
{
StringArray frameworks;
frameworks.addTokens (getEmbeddedFrameworksString(), true);
frameworks.trim();
return frameworks;
}
void addCustomResourceFolders() const void addCustomResourceFolders() const
{ {
StringArray folders; StringArray folders;
@@ -2778,6 +2837,35 @@ private:
return addBuildFile (path, fileRefID, false, false); return addBuildFile (path, fileRefID, false, false);
} }
String addCustomFramework (String frameworkPath) const
{
if (! frameworkPath.endsWithIgnoreCase (".framework"))
frameworkPath << ".framework";
auto fileRefID = createFileRefID (frameworkPath);
auto fileType = getFileType (RelativePath (frameworkPath, RelativePath::projectFolder));
addFileOrFolderReference (frameworkPath, "<group>", fileType);
frameworkFileIDs.add (fileRefID);
return addBuildFile (frameworkPath, fileRefID, false, false);
}
String addEmbeddedFramework (const String& path) const
{
auto fileRefID = createFileRefID (path);
auto fileID = createID (path + "buildref");
auto* v = new ValueTree (fileID);
v->setProperty ("isa", "PBXBuildFile", nullptr);
v->setProperty ("fileRef", fileRefID, nullptr);
v->setProperty ("settings", "{ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }", nullptr);
pbxBuildFiles.add (v);
return fileID;
}
void addGroup (const String& groupID, const String& groupName, const StringArray& childIDs) const void addGroup (const String& groupID, const String& groupName, const StringArray& childIDs) const
{ {
auto* v = new ValueTree (groupID); auto* v = new ValueTree (groupID);


+ 2
- 0
extras/Projucer/Source/Utility/Helpers/jucer_PresetIDs.h View File

@@ -126,6 +126,8 @@ namespace Ids
DECLARE_ID (osxArchitecture); DECLARE_ID (osxArchitecture);
DECLARE_ID (iosCompatibility); DECLARE_ID (iosCompatibility);
DECLARE_ID (extraFrameworks); DECLARE_ID (extraFrameworks);
DECLARE_ID (extraCustomFrameworks);
DECLARE_ID (embeddedFrameworks);
DECLARE_ID (extraDLLs); DECLARE_ID (extraDLLs);
DECLARE_ID (winArchitecture); DECLARE_ID (winArchitecture);
DECLARE_ID (winWarningLevel); DECLARE_ID (winWarningLevel);


Loading…
Cancel
Save