Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion commandLine/src/defines.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define OFPROJECTGENERATOR_MAJOR_VERSION "0"
#define OFPROJECTGENERATOR_MINOR_VERSION "126"
#define OFPROJECTGENERATOR_MINOR_VERSION "127"
#define OFPROJECTGENERATOR_PATCH_VERSION "0"

#define PG_VERSION (OFPROJECTGENERATOR_MAJOR_VERSION "." OFPROJECTGENERATOR_MINOR_VERSION "." OFPROJECTGENERATOR_PATCH_VERSION)
Expand Down
293 changes: 293 additions & 0 deletions commandLine/src/projects/XcodeResources.h

Large diffs are not rendered by default.

60 changes: 37 additions & 23 deletions commandLine/src/projects/xcodeProject.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "xcodeProject.h"
#include "XcodeSettings.h"
#include "XcodeResources.h"
#include "Utils.h"
#include "ofUtils.h"
#include <nlohmann/json.hpp>
Expand Down Expand Up @@ -155,13 +156,17 @@ bool xcodeProject::readAppleSettings() {
for (auto & record : sdk) {
if (!record.at("scope").is_string() || !record.at("references").is_object()) throw std::runtime_error("invalid SDK reference baseline");
}
xcodeResources::validate(appleDefaults.value("resources", json::object()));
}
xcodeSettings::configurations(xcodeSettings::readProject(readSettingsFile(templatePath / "emptyExample.xcodeproj/project.pbxproj")));
auto templateProject = xcodeSettings::readProject(readSettingsFile(templatePath / "emptyExample.xcodeproj/project.pbxproj"));
xcodeSettings::configurations(templateProject);
xcodeResources::snapshot(templateProject);
auto projectFile = projectDir / (projectName + ".xcodeproj") / "project.pbxproj";
if (fs::exists(projectFile)) {
appleProject = xcodeSettings::readProject(readSettingsFile(projectFile));
xcodeSettings::configurations(appleProject);
targetAttributes(appleProject);
xcodeResources::snapshot(appleProject);
}
for (auto name : { "Project.xcconfig", "openFrameworks-Info.plist", "of.entitlements", "ofxiOS-Info.plist" }) {
if (!fs::exists(templatePath / name)) continue;
Expand Down Expand Up @@ -194,6 +199,8 @@ bool xcodeProject::readAppleSettings() {
}

void xcodeProject::mergeAppleSettings(json & project) {
nextAppleDefaults["resources"] = xcodeResources::merge(project, appleProject, appleDefaults.value("resources", json::object()),
projectDir, getOFRoot(), [] { return generateUUID(string("preserved-resource")); });
mergeSystemReferences(project);
appleSDKKeys.clear();
if (!appleProject.empty() && (systemFrameworksPassed || systemLibsPassed)) {
Expand Down Expand Up @@ -446,14 +453,20 @@ bool xcodeProject::createProjectFile() {
// FIXME: rootReplacements can be empty.
// if project is outside OF, rootReplacements is set to be used in XCode and make
if (!fs::equivalent(getOFRoot(), normalizePath(fs::path { "../../.." }))) {
string root { ofPathToString(getOFRoot()) };
string root { getOFRoot().generic_string() };
rootReplacements = { "../../..", root };
}
// Template substitutions occur inside JSON strings. Native Windows separators
// and quotes in names must be escaped before readTemplateUUIDs parses the copy.
auto jsonText = [](const string & text) {
auto quoted = json(text).dump();
return quoted.substr(1, quoted.size() - 2);
};

copyTemplateFiles.push_back({ normalizePath(templatePath / "emptyExample.xcodeproj" / "project.pbxproj"),
normalizePath(xcodeProject / "project.pbxproj"),
{ { "emptyExample", projectName },
rootReplacements } });
{ { "emptyExample", jsonText(projectName) },
{ rootReplacements.first, jsonText(rootReplacements.second) } } });

copyTemplateFiles.push_back({ normalizePath(templatePath / "Project.xcconfig"),
normalizePath(projectDir / "Project.xcconfig"),
Expand Down Expand Up @@ -628,7 +641,8 @@ void xcodeProject::readTemplateUUIDs() {
if (!exists(a.sources)) a.sources = found[0].sources;
if (!exists(a.frameworks)) a.frameworks = found[0].frameworks;
if (!exists(a.copyFrameworks)) a.copyFrameworks = found[0].copyFrameworks;
if (!exists(a.resources)) a.resources = found[0].resources;
// An unused template phase may still exist in objects without belonging to this target.
a.resources = found[0].resources;
buildConfigurationListUUID = a.uuid;
buildActionMaskUUID = a.sources;
uuidMap["linkBinaryWithLibraries"] = a.frameworks;
Expand Down Expand Up @@ -910,19 +924,20 @@ void xcodeProject::addSrc(const fs::path & srcFile, const fs::path & folder, Src
fp.addToBuildResource = true;
fp.addToResources = true;
} else if (ext == ".metal") {
fp.addToBuildResource = true;
fp.addToResources = true;
// Metal sources are compiled into the target's default.metallib.
} else if (ext == ".entitlements") {
fp.addToBuildPhase = false;
fp.addToBuildResource = true;
fp.addToResources = true;
} else if (ext == ".info") {
fp.addToBuildPhase = false;
fp.addToBuildResource = true;
fp.addToResources = true;
} else if (ext == ".storyboard") {
fp.addToBuildPhase = false;
fp.copyBundleResources = true;
} else if (ext == ".plist") {
fp.addToBuildPhase = true;
fp.addToBuildPhase = false;
fp.copyBundleResources = true;
} else if (ext == ".swift") {
fp.addToBuildPhase = true;
Expand All @@ -931,13 +946,18 @@ void xcodeProject::addSrc(const fs::path & srcFile, const fs::path & folder, Src
// mark all Swift files as C++ interop available :)
}
} else if (ext == ".xcassets") {
fp.addToBuildPhase = false;
fp.addToBuildResource = true;
fp.addToResources = true;
} else if (ext == ".modulemap") {
fp.addToBuildPhase = false;
} else if (ext == ".bundle") {
fp.addToBuildPhase = false;
fp.addToBuildResource = true;
fp.addToResources = true;
} else if (ext == ".icns") {
fp.addToBuildPhase = false;
fp.copyBundleResources = true;
} else if (ext == ".tbd") {
fp.linkBinaryWithLibraries = true;
}
Expand Down Expand Up @@ -1336,7 +1356,15 @@ string xcodeProject::addFile(const fs::path & path, const fs::path & folder, con
addCommand("Add :objects:" + t.sources + ":files: string " + buildUUID);
}

if (fp.copyBundleResources && !t.resources.empty()) {
if (fp.copyBundleResources || fp.addToBuildResource || fp.addToResources) {
if (t.resources.empty()) {
t.resources = generateUUID("resources-" + t.uuid);
addCommand("Add :objects:" + t.resources + ":isa string PBXResourcesBuildPhase");
addCommand("Add :objects:" + t.resources + ":buildActionMask string 2147483647");
addCommand("Add :objects:" + t.resources + ":runOnlyForDeploymentPostprocessing string 0");
addCommand("Add :objects:" + t.resources + ":files array");
addCommand("Add :objects:" + t.uuid + ":buildPhases: string " + t.resources);
}
addCommand("# ---- copyBundleResources");
addCommand("Add :objects:" + t.resources + ":files: string " + buildUUID);
}
Expand All @@ -1355,20 +1383,6 @@ string xcodeProject::addFile(const fs::path & path, const fs::path & folder, con
addCommand("Add :objects:" + buildUUID + ":settings:ATTRIBUTES: string CodeSignOnCopy");
}

if (i == 0 && fp.addToBuildResource) {
string mediaAssetsUUID { "9936F60E1BFA4DEE00891288" };
addCommand("# ---- addToBuildResource");
addCommand("Add :objects:" + mediaAssetsUUID + ":files: string " + UUID);
}

if (i == 0 && fp.addToResources) {
// FIXME: test if it is working on iOS
if (resourcesUUID != "") {
addCommand("# ---- addToResources (IOS only) ?" + buildUUID);
addCommand("Add :objects:" + resourcesUUID + ": string " + buildUUID);
}
}

if (fp.linkBinaryWithLibraries && !t.frameworks.empty()) { // Link Binary With Libraries
auto tempUUID = generateUUID(ofPathToString(path) + "-InFrameworks" + suffix);
addCommand("Add :objects:" + tempUUID + ":fileRef string " + UUID);
Expand Down
2 changes: 2 additions & 0 deletions commandLine/src/projects/xcodeProject.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ class xcodeProject : public baseProject {
{ ".plist" , "text.plist.xml" },

{ ".storyboard" , "wrapper.storyboard" },
{ ".icns" , "image.icns" },
{ ".xcassets" , "folder.assetcatalog" },
};

// other uuid strings can be ported to here.
Expand Down
5 changes: 3 additions & 2 deletions frontend/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ function clearProjectSettings() {
ipcRenderer.on('setProjectSettings', (event, values) => {
if (values.projectName !== $('#projectName').val() || values.projectPath !== $('#projectPath').val()) return;
const fields = { appVersion: values.version || '', appBuild: values.build || '', bundleId: values.bundleId || '',
systemFrameworks: (values.frameworks || []).join(','), systemLibs: (values.libs || []).join(','), customDefines: (values.defines || []).join(',') };
systemFrameworks: (values.frameworks || []).join(', '), systemLibs: (values.libs || []).join(','), customDefines: (values.defines || []).join(',') };
const keepEdits = values.preserveEdits && loadedProjectSettings?.projectName === values.projectName && loadedProjectSettings?.projectPath === values.projectPath;
for (const [id, value] of Object.entries(fields)) {
if (!keepEdits || $('#' + id).val().trim() === loadedProjectSettings[id]) $('#' + id).val(value);
Expand All @@ -246,7 +246,8 @@ ipcRenderer.on('setProjectSettings', (event, values) => {
function projectFieldValue(id) {
const value = $('#' + id).val().trim();
if (loadedProjectSettings && (loadedProjectSettings.projectName !== $('#projectName').val() || loadedProjectSettings.projectPath !== $('#projectPath').val())) return null;
return loadedProjectSettings && loadedProjectSettings[id] === value ? null : value;
const normalize = (text) => ['systemFrameworks', 'systemLibs'].includes(id) ? text.split(/[\s,]+/).filter(Boolean).join(',') : text;
return loadedProjectSettings && normalize(loadedProjectSettings[id]) === normalize(value) ? null : value;
}

//-------------------------------------------
Expand Down
8 changes: 4 additions & 4 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,11 @@
<div class="two fields" id="systemFrameworksField" style="display: none">
<div class="field">
<label><span data-i18n="field.systemFrameworks">System frameworks:</span> &nbsp;
<a class="ui icon tooltip" href="#" data-i18n-content="tooltip.systemFrameworks" data-content="Apple SDK frameworks, comma-separated, e.g. Security,CoreBluetooth. Saved in config.make PROJECT_FRAMEWORKS." data-position="right center">
<a class="ui icon tooltip" href="#" data-i18n-content="tooltip.systemFrameworks" data-content="Apple SDK frameworks, comma-separated, e.g. Security, CoreBluetooth. Saved in config.make PROJECT_FRAMEWORKS." data-position="right center">
<i class="help circle icon"></i>
</a>
</label>
<input type="text" id="systemFrameworks" placeholder="Security,CoreBluetooth" autocomplete="off" spellcheck="false">
<input type="text" id="systemFrameworks" placeholder="Security, CoreBluetooth" autocomplete="off" spellcheck="false">
</div>
<div class="field">
<label><span data-i18n="field.systemLibs">System libraries:</span> &nbsp;
Expand Down Expand Up @@ -580,7 +580,7 @@ <h4 class="ui dividing header">Platforms and templates</h4>
<h4 class="ui dividing header">System frameworks and libraries (macOS / iOS / tvOS)</h4>
<p>With <b>Advanced options</b> on and an Apple platform selected, add SDK frameworks and libraries the project links to, separated by commas or spaces:</p>
<ul>
<li><b>System frameworks</b>: <code>Security,CoreBluetooth</code> - Security.framework, CoreBluetooth.framework</li>
<li><b>System frameworks</b>: <code>Security, CoreBluetooth</code> - Security.framework, CoreBluetooth.framework</li>
<li><b>System libraries</b>: <code>sqlite3,z</code> - libsqlite3.tbd, libz.tbd (<code>libsqlite3</code>, <code>libsqlite3.tbd</code> and <code>-lsqlite3</code> also work)</li>
</ul>
<p>They are saved with the project in <code>config.make</code>, so updating the project or opening it on another machine keeps them:</p>
Expand All @@ -597,7 +597,7 @@ <h4 class="ui dividing header">Downloads</h4>
<h4 class="ui dividing header">Command line</h4>
<p>The PG app runs the <code>projectGenerator</code> command line, which can be used on its own:</p>
<pre class="helpCode">projectGenerator -o"path/to/openFrameworks" -a"ofxGui,ofxOsc" -p"osx" "path/to/myApp"
projectGenerator -o"path/to/openFrameworks" -p"ios" -f"Security,CoreBluetooth" --system-libs="sqlite3" "path/to/myApp"
projectGenerator -o"path/to/openFrameworks" -p"ios" -f"Security, CoreBluetooth" --system-libs="sqlite3" "path/to/myApp"
projectGenerator -o"path/to/openFrameworks" -r -p"osx" "path/to/examples"
projectGenerator --help</pre>
<p>Run without <code>-a</code>, <code>-f</code> or <code>--system-libs</code> to keep what the project's <code>addons.make</code> / <code>config.make</code> already have. An empty <code>-f</code> / <code>--system-libs=</code> removes them.</p>
Expand Down
2 changes: 1 addition & 1 deletion frontend/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
"tooltip.bundleIdInvalid": "Die Bundle-ID darf nur Buchstaben, Ziffern, - und Punkte enthalten, z. B. com.example.myApp.",
"field.systemFrameworks": "System-Frameworks:",
"field.systemLibs": "System-Bibliotheken:",
"tooltip.systemFrameworks": "Apple-SDK-Frameworks, durch Kommas getrennt, z. B. Security,CoreBluetooth. Gespeichert in config.make PROJECT_FRAMEWORKS.",
"tooltip.systemFrameworks": "Apple-SDK-Frameworks, durch Kommas getrennt, z. B. Security, CoreBluetooth. Gespeichert in config.make PROJECT_FRAMEWORKS.",
"tooltip.systemLibs": "SDK-Bibliotheken, durch Kommas getrennt, z. B. sqlite3,z für libsqlite3.tbd und libz.tbd. Gespeichert in config.make PROJECT_SYSTEM_LIBS.",
"tooltip.appVersionInvalid": "Die Version darf nur Ziffern und Punkte enthalten, z. B. 1, 1.2 oder 1.2.3.",
"tooltip.appBuildInvalid": "Der Build muss eine positive ganze Zahl sein, z. B. 42.",
Expand Down
2 changes: 1 addition & 1 deletion frontend/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
"tooltip.bundleIdInvalid": "Bundle ID should be letters, digits, - and dots, e.g. com.example.myApp.",
"field.systemFrameworks": "System frameworks:",
"field.systemLibs": "System libraries:",
"tooltip.systemFrameworks": "Apple SDK frameworks, comma-separated, e.g. Security,CoreBluetooth. Saved in config.make PROJECT_FRAMEWORKS.",
"tooltip.systemFrameworks": "Apple SDK frameworks, comma-separated, e.g. Security, CoreBluetooth. Saved in config.make PROJECT_FRAMEWORKS.",
"tooltip.systemLibs": "SDK libraries, comma-separated, e.g. sqlite3,z for libsqlite3.tbd and libz.tbd. Saved in config.make PROJECT_SYSTEM_LIBS.",
"tooltip.appVersionInvalid": "Version should be digits and dots, e.g. 1, 1.2 or 1.2.3.",
"tooltip.appBuildInvalid": "Build should be a positive whole number, e.g. 42.",
Expand Down
2 changes: 1 addition & 1 deletion frontend/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
"tooltip.bundleIdInvalid": "El ID de paquete debe tener letras, dígitos, - y puntos, p. ej. com.example.myApp.",
"field.systemFrameworks": "Frameworks del sistema:",
"field.systemLibs": "Bibliotecas del sistema:",
"tooltip.systemFrameworks": "Frameworks del SDK de Apple, separados por comas, p. ej. Security,CoreBluetooth. Se guardan en config.make PROJECT_FRAMEWORKS.",
"tooltip.systemFrameworks": "Frameworks del SDK de Apple, separados por comas, p. ej. Security, CoreBluetooth. Se guardan en config.make PROJECT_FRAMEWORKS.",
"tooltip.systemLibs": "Bibliotecas del SDK, separadas por comas, p. ej. sqlite3,z para libsqlite3.tbd y libz.tbd. Se guardan en config.make PROJECT_SYSTEM_LIBS.",
"tooltip.appVersionInvalid": "La versión debe contener solo dígitos y puntos, p. ej. 1, 1.2 o 1.2.3.",
"tooltip.appBuildInvalid": "La compilación debe ser un número entero positivo, p. ej. 42.",
Expand Down
2 changes: 1 addition & 1 deletion frontend/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
"tooltip.bundleIdInvalid": "L'ID de bundle doit contenir des lettres, chiffres, - et points, ex. com.example.myApp.",
"field.systemFrameworks": "Frameworks système :",
"field.systemLibs": "Bibliothèques système :",
"tooltip.systemFrameworks": "Frameworks du SDK Apple, séparés par des virgules, ex. Security,CoreBluetooth. Enregistrés dans config.make PROJECT_FRAMEWORKS.",
"tooltip.systemFrameworks": "Frameworks du SDK Apple, séparés par des virgules, ex. Security, CoreBluetooth. Enregistrés dans config.make PROJECT_FRAMEWORKS.",
"tooltip.systemLibs": "Bibliothèques du SDK, séparées par des virgules, ex. sqlite3,z pour libsqlite3.tbd et libz.tbd. Enregistrées dans config.make PROJECT_SYSTEM_LIBS.",
"tooltip.appVersionInvalid": "La version doit contenir uniquement des chiffres et des points, p. ex. 1, 1.2 ou 1.2.3.",
"tooltip.appBuildInvalid": "Le build doit être un entier positif, p. ex. 42.",
Expand Down
2 changes: 1 addition & 1 deletion frontend/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
"tooltip.bundleIdInvalid": "バンドルIDは英数字、- とドットのみ使用できます(例: com.example.myApp)。",
"field.systemFrameworks": "システムフレームワーク:",
"field.systemLibs": "システムライブラリ:",
"tooltip.systemFrameworks": "Apple SDK のフレームワーク(カンマ区切り、例: Security,CoreBluetooth)。config.make の PROJECT_FRAMEWORKS に保存されます。",
"tooltip.systemFrameworks": "Apple SDK のフレームワーク(カンマ区切り、例: Security, CoreBluetooth)。config.make の PROJECT_FRAMEWORKS に保存されます。",
"tooltip.systemLibs": "SDK のライブラリ(カンマ区切り、例: sqlite3,z で libsqlite3.tbd と libz.tbd)。config.make の PROJECT_SYSTEM_LIBS に保存されます。",
"tooltip.appVersionInvalid": "バージョンは数字とドットのみで指定してください (例: 1、1.2、1.2.3)。",
"tooltip.appBuildInvalid": "ビルドは正の整数で指定してください (例: 42)。",
Expand Down
2 changes: 1 addition & 1 deletion frontend/locales/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
"tooltip.bundleIdInvalid": "번들 ID는 문자, 숫자, - 및 점만 사용할 수 있습니다(예: com.example.myApp).",
"field.systemFrameworks": "시스템 프레임워크:",
"field.systemLibs": "시스템 라이브러리:",
"tooltip.systemFrameworks": "Apple SDK 프레임워크(쉼표로 구분, 예: Security,CoreBluetooth). config.make의 PROJECT_FRAMEWORKS에 저장됩니다.",
"tooltip.systemFrameworks": "Apple SDK 프레임워크(쉼표로 구분, 예: Security, CoreBluetooth). config.make의 PROJECT_FRAMEWORKS에 저장됩니다.",
"tooltip.systemLibs": "SDK 라이브러리(쉼표로 구분, 예: sqlite3,z = libsqlite3.tbd, libz.tbd). config.make의 PROJECT_SYSTEM_LIBS에 저장됩니다.",
"tooltip.appVersionInvalid": "버전은 숫자와 점만 사용할 수 있습니다 (예: 1, 1.2, 1.2.3).",
"tooltip.appBuildInvalid": "빌드는 양의 정수여야 합니다 (예: 42).",
Expand Down
2 changes: 1 addition & 1 deletion frontend/locales/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
"tooltip.bundleIdInvalid": "O ID do pacote deve ter letras, dígitos, - e pontos, ex. com.example.myApp.",
"field.systemFrameworks": "Frameworks do sistema:",
"field.systemLibs": "Bibliotecas do sistema:",
"tooltip.systemFrameworks": "Frameworks do SDK da Apple, separados por vírgulas, ex. Security,CoreBluetooth. Salvos em config.make PROJECT_FRAMEWORKS.",
"tooltip.systemFrameworks": "Frameworks do SDK da Apple, separados por vírgulas, ex. Security, CoreBluetooth. Salvos em config.make PROJECT_FRAMEWORKS.",
"tooltip.systemLibs": "Bibliotecas do SDK, separadas por vírgulas, ex. sqlite3,z para libsqlite3.tbd e libz.tbd. Salvas em config.make PROJECT_SYSTEM_LIBS.",
"tooltip.appVersionInvalid": "A versão deve conter apenas dígitos e pontos, ex.: 1, 1.2 ou 1.2.3.",
"tooltip.appBuildInvalid": "O build deve ser um número inteiro positivo, ex.: 42.",
Expand Down
2 changes: 1 addition & 1 deletion frontend/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
"tooltip.bundleIdInvalid": "Bundle ID может содержать буквы, цифры, - и точки, например com.example.myApp.",
"field.systemFrameworks": "Системные фреймворки:",
"field.systemLibs": "Системные библиотеки:",
"tooltip.systemFrameworks": "Фреймворки Apple SDK через запятую, например Security,CoreBluetooth. Сохраняются в config.make PROJECT_FRAMEWORKS.",
"tooltip.systemFrameworks": "Фреймворки Apple SDK через запятую, например Security, CoreBluetooth. Сохраняются в config.make PROJECT_FRAMEWORKS.",
"tooltip.systemLibs": "Библиотеки SDK через запятую, например sqlite3,z для libsqlite3.tbd и libz.tbd. Сохраняются в config.make PROJECT_SYSTEM_LIBS.",
"tooltip.appVersionInvalid": "Версия должна состоять из цифр и точек, например 1, 1.2 или 1.2.3.",
"tooltip.appBuildInvalid": "Номер сборки должен быть целым положительным числом, например 42.",
Expand Down
Loading
Loading