diff --git a/commandLine/compile_flags.txt b/commandLine/compile_flags.txt new file mode 100644 index 00000000..07ccbadf --- /dev/null +++ b/commandLine/compile_flags.txt @@ -0,0 +1,61 @@ +-Wno-c++11-extensions +-std=c17 +-std=c++2b +-fobjc-arc +-lstdc++fs +-stdlib=libc++ +-mmacosx-version-min=12.0 +-MMD +-MP +-MF +-O3 +-mtune=native +-DNDEBUG +-Wall +-Werror=return-type +-fexceptions +-fpascal-strings +-x +objective-c++ +-I../../../libs/openFrameworks +-I../../../libs/openFrameworks/3d +-I../../../libs/openFrameworks/app +-I../../../libs/openFrameworks/communication +-I../../../libs/openFrameworks/events +-I../../../libs/openFrameworks/gl +-I../../../libs/openFrameworks/graphics +-I../../../libs/openFrameworks/math +-I../../../libs/openFrameworks/sound +-I../../../libs/openFrameworks/types +-I../../../libs/openFrameworks/utils +-I../../../libs/openFrameworks/video +-I../../../libs/FreeImage/include +-I../../../libs/brotli/include +-I../../../libs/cairo/include +-I../../../libs/curl/include +-I../../../libs/fmt/include +-I../../../libs/freetype/include +-I../../../libs/glew/include +-I../../../libs/glfw/include +-I../../../libs/glm/include +-I../../../libs/json/include +-I../../../libs/kiss/include +-I../../../libs/libpng/include +-I../../../libs/libusb/include +-I../../../libs/metalangle/include +-I../../../libs/openssl/include +-I../../../libs/pixman/include +-I../../../libs/pugixml/include +-I../../../libs/rtAudio/include +-I../../../libs/tess2/include +-I../../../libs/uriparser/include +-I../../../libs/utf8/include +-I../../../libs/zlib/include + + +-Isrc +-Isrc/addons +-Isrc/projects +-Isrc/utils +-Isrc/uuidxx +-Isrc/uuidxx/src diff --git a/commandLine/src/defines.h b/commandLine/src/defines.h index 4fbd05e2..90a36af3 100644 --- a/commandLine/src/defines.h +++ b/commandLine/src/defines.h @@ -1,5 +1,5 @@ #define OFPROJECTGENERATOR_MAJOR_VERSION "0" -#define OFPROJECTGENERATOR_MINOR_VERSION "92" +#define OFPROJECTGENERATOR_MINOR_VERSION "93" #define OFPROJECTGENERATOR_PATCH_VERSION "0" #define PG_VERSION (OFPROJECTGENERATOR_MAJOR_VERSION "." OFPROJECTGENERATOR_MINOR_VERSION "." OFPROJECTGENERATOR_PATCH_VERSION) diff --git a/commandLine/src/projects/xcodeProject.cpp b/commandLine/src/projects/xcodeProject.cpp index 6c10a13d..476a037e 100644 --- a/commandLine/src/projects/xcodeProject.cpp +++ b/commandLine/src/projects/xcodeProject.cpp @@ -3,36 +3,37 @@ #include "ofUtils.h" #include #ifdef __APPLE__ - #include // std::system + #include // std::system // #include #endif -#include #include +#include using nlohmann::json; -using nlohmann::json_pointer; string xcodeProject::LOG_NAME = "xcodeProjectFile"; -xcodeProject::xcodeProject(const string & target) : baseProject(target){ +xcodeProject::xcodeProject(const string & target) + : baseProject(target) { // TODO: remove unused variables - if( target == "osx" ){ + if (target == "osx") { folderUUID = { - { "src", "E4B69E1C0A3A1BDC003C02F2" }, - { "addons", "BB4B014C10F69532006C3DED" }, + { "src", "E4B69E1C0A3A1BDC003C02F2" }, + { "addons", "BB4B014C10F69532006C3DED" }, { "openFrameworks", "191EF70929D778A400F35F26" }, - { "", "E4B69B4A0A3A1720003C02F2" } + { "", "E4B69B4A0A3A1720003C02F2" } // { "localAddons", "6948EE371B920CB800B5AC1A" }, }; buildConfigurationListUUID = "E4B69B5A0A3A1756003C02F2"; buildActionMaskUUID = "E4B69B580A3A1756003C02F2"; - projRootUUID = "E4B69B4A0A3A1720003C02F2"; - resourcesUUID = ""; - frameworksUUID = "E7E077E715D3B6510020DFD4"; //PBXFrameworksBuildPhase - afterPhaseUUID = "928F60851B6710B200E2D791"; - buildPhasesUUID = "E4C2427710CC5ABF004149E2"; + projRootUUID = "E4B69B4A0A3A1720003C02F2"; + resourcesUUID = ""; +// frameworksUUID = "E7E077E715D3B6510020DFD4"; //PBXFrameworksBuildPhase + afterPhaseUUID = "928F60851B6710B200E2D791"; + buildPhasesUUID = "E4C2427710CC5ABF004149E2"; + uuidMap["linkBinaryWithLibraries"] = "E4B69B590A3A1756003C02F2"; } else { // IOS @@ -44,77 +45,73 @@ xcodeProject::xcodeProject(const string & target) : baseProject(target){ buildConfigs[0] = "1D6058940D05DD3E006BFB54"; // iOS Debug buildConfigs[1] = "1D6058950D05DD3E006BFB54"; // iOS Release -// buildConfigs[0] = "C01FCF4F08A954540054247B"; // iOS Debug -// buildConfigs[1] = "C01FCF5008A954540054247B"; // iOS Release + // buildConfigs[0] = "C01FCF4F08A954540054247B"; // iOS Debug + // buildConfigs[1] = "C01FCF5008A954540054247B"; // iOS Release folderUUID = { - { "src", "E4D8936A11527B74007E1F53" }, - { "addons", "BB16F26B0F2B646B00518274" }, - { "", "29B97314FDCFA39411CA2CEA" }, - { "Frameworks", "901808C02053638E004A7774" } + { "src", "E4D8936A11527B74007E1F53" }, + { "addons", "BB16F26B0F2B646B00518274" }, + { "", "29B97314FDCFA39411CA2CEA" }, + { "Frameworks", "901808C02053638E004A7774" } // { "localAddons", "6948EE371B920CB800B5AC1A" }, }; buildConfigurationListUUID = "1D6058900D05DD3D006BFB54"; //check - buildActionMaskUUID = "1D60588E0D05DD3D006BFB54"; - projRootUUID = "29B97314FDCFA39411CA2CEA"; //mainGroup — OK - resourcesUUID = "BB24DD8F10DA77E000E9C588"; - copyBundleResourcesUUID = "1D60588D0D05DD3D006BFB54"; - frameworksUUID = "1DF5F4E00D08C38300B7A737"; //PBXFrameworksBuildPhase // todo: check this? - afterPhaseUUID = "928F60851B6710B200E2D791"; + buildActionMaskUUID = "1D60588E0D05DD3D006BFB54"; + projRootUUID = "29B97314FDCFA39411CA2CEA"; //mainGroup — OK + resourcesUUID = "BB24DD8F10DA77E000E9C588"; + copyBundleResourcesUUID = "1D60588D0D05DD3D006BFB54"; +// frameworksUUID = "1DF5F4E00D08C38300B7A737"; //PBXFrameworksBuildPhase // todo: check this? + afterPhaseUUID = "928F60851B6710B200E2D791"; buildPhasesUUID = "9255DD331112741900D6945E"; + uuidMap["linkBinaryWithLibraries"] = "1D60588F0D05DD3D006BFB54"; } }; -bool xcodeProject::createProjectFile(){ - fs::path xcodeProject = projectDir / ( projectName + ".xcodeproj" ); +bool xcodeProject::createProjectFile() { + fs::path xcodeProject = projectDir / (projectName + ".xcodeproj"); try { - fs::create_directories(xcodeProject); - } catch (const std::exception& e) { - std::cerr << "Error creating directories: " << e.what() << std::endl; - return false; - } - - // 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()) }; - rootReplacements = { "../../..", root }; - } - - - copyTemplateFiles.push_back({ - normalizePath(templatePath / "emptyExample.xcodeproj" / "project.pbxproj"), - normalizePath(xcodeProject / "project.pbxproj"), - {{"emptyExample", projectName}, - rootReplacements} - }); - - copyTemplateFiles.push_back({ - normalizePath(templatePath / "Project.xcconfig"), - normalizePath(projectDir / "Project.xcconfig"), - {rootReplacements} - }); - - if (target == "osx" || target == "macos") { - for (auto & f : {"openFrameworks-Info.plist", "of.entitlements"}) { - copyTemplateFiles.push_back({normalizePath(templatePath / f), normalizePath(projectDir / f)}); - } - } else if (target == "ios" || target == "tvos" || target == "visionos" || target == "catos" || target == "macos") { - for (auto & f : {"ofxiOS-Info.plist", "ofxiOS_Prefix.pch"}) { - copyTemplateFiles.push_back({normalizePath(templatePath / f), normalizePath(projectDir / f)}); - try { - fs::path from = normalizePath(templatePath / "mediaAssets"); - fs::path to = normalizePath(projectDir / "mediaAssets"); - if (!fs::exists(to)) { - fs::copy(from, to, fs::copy_options::recursive | fs::copy_options::update_existing); - } - } catch (const std::exception& e) { - std::cerr << "Error copying template files: " << e.what() << std::endl; - return false; - } - } - } + fs::create_directories(xcodeProject); + } catch (const std::exception & e) { + std::cerr << "Error creating directories: " << e.what() << std::endl; + return false; + } + + // 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()) }; + rootReplacements = { "../../..", root }; + } + + copyTemplateFiles.push_back({ normalizePath(templatePath / "emptyExample.xcodeproj" / "project.pbxproj"), + normalizePath(xcodeProject / "project.pbxproj"), + { { "emptyExample", projectName }, + rootReplacements } }); + + copyTemplateFiles.push_back({ normalizePath(templatePath / "Project.xcconfig"), + normalizePath(projectDir / "Project.xcconfig"), + { rootReplacements } }); + + if (target == "osx" || target == "macos") { + for (auto & f : { "openFrameworks-Info.plist", "of.entitlements" }) { + copyTemplateFiles.push_back({ normalizePath(templatePath / f), normalizePath(projectDir / f) }); + } + } else if (target == "ios" || target == "tvos" || target == "visionos" || target == "catos" || target == "macos") { + for (auto & f : { "ofxiOS-Info.plist", "ofxiOS_Prefix.pch" }) { + copyTemplateFiles.push_back({ normalizePath(templatePath / f), normalizePath(projectDir / f) }); + try { + fs::path from = normalizePath(templatePath / "mediaAssets"); + fs::path to = normalizePath(projectDir / "mediaAssets"); + if (!fs::exists(to)) { + fs::copy(from, to, fs::copy_options::recursive | fs::copy_options::update_existing); + } + } catch (const std::exception & e) { + std::cerr << "Error copying template files: " << e.what() << std::endl; + return false; + } + } + } if (backupProjectFiles) { createBackup({ xcodeProject / "project.pbxproj" }, projectDir); @@ -128,7 +125,7 @@ bool xcodeProject::createProjectFile(){ saveScheme(); - if(target == "osx" || target == "macos"){ + if (target == "osx" || target == "macos") { saveMakefile(); } @@ -136,7 +133,7 @@ bool xcodeProject::createProjectFile(){ for (auto & c : copyTemplateFiles) { try { c.run(); - } catch (const std::exception& e) { + } catch (const std::exception & e) { std::cerr << "Error running copy template files: " << e.what() << std::endl; return false; } @@ -164,11 +161,11 @@ bool xcodeProject::createProjectFile(){ // extended attributes on macOS std::string command = "xattr -w com.apple.xcode.CreatedByBuildSystem true " + templateBinDir.string(); if (std::system(command.c_str()) != 0) { - std::cerr << "Failed to set extended attributes on " << templateBinDir.string() << std::endl; + std::cerr << "Failed to set extended attributes on " << templateBinDir.string() << std::endl; } else { ofLogVerbose("xcodeProject") << "xattr set correctly for /bin" << endl; } - } catch (const std::exception& e) { + } catch (const std::exception & e) { std::cout << "xcodeProject::createProjectFile() error " << e.what() << std::endl; } #endif @@ -177,8 +174,8 @@ bool xcodeProject::createProjectFile(){ return true; } -void xcodeProject::saveScheme(){ - auto schemeFolder = projectDir / ( projectName + ".xcodeproj" ) / "xcshareddata/xcschemes"; +void xcodeProject::saveScheme() { + auto schemeFolder = projectDir / (projectName + ".xcodeproj") / "xcshareddata/xcschemes"; if (fs::exists(schemeFolder)) { fs::remove_all(schemeFolder); @@ -187,40 +184,29 @@ void xcodeProject::saveScheme(){ if (target == "osx") { for (auto & f : { "Release", "Debug" }) { - copyTemplateFiles.push_back({ - templatePath / ("emptyExample.xcodeproj/xcshareddata/xcschemes/emptyExample " + string(f) + ".xcscheme"), - schemeFolder / (projectName + " " +f+ ".xcscheme"), - {{ "emptyExample", projectName }} - }); + copyTemplateFiles.push_back({ templatePath / ("emptyExample.xcodeproj/xcshareddata/xcschemes/emptyExample " + string(f) + ".xcscheme"), + schemeFolder / (projectName + " " + f + ".xcscheme"), + { { "emptyExample", projectName } } }); } - copyTemplateFiles.push_back({ - projectDir / (projectName + ".xcodeproj/project.xcworkspace"), - templatePath / "emptyExample.xcodeproj/project.xcworkspace" - }); + copyTemplateFiles.push_back({ projectDir / (projectName + ".xcodeproj/project.xcworkspace"), + templatePath / "emptyExample.xcodeproj/project.xcworkspace" }); } else { // MARK:- IOS sector; - copyTemplateFiles.push_back({ - templatePath / "emptyExample.xcodeproj/xcshareddata/xcschemes/emptyExample.xcscheme", + copyTemplateFiles.push_back({ templatePath / "emptyExample.xcodeproj/xcshareddata/xcschemes/emptyExample.xcscheme", schemeFolder / (projectName + ".xcscheme"), - {{ "emptyExample", projectName }} - }); + { { "emptyExample", projectName } } }); } } -void xcodeProject::saveMakefile(){ - copyTemplateFiles.push_back({ - templatePath / "Makefile", projectDir / "Makefile", - { rootReplacements } - }); - copyTemplateFiles.push_back({ - templatePath / "config.make", projectDir / "config.make" - }); +void xcodeProject::saveMakefile() { + copyTemplateFiles.push_back({ templatePath / "Makefile", projectDir / "Makefile", + { rootReplacements } }); + copyTemplateFiles.push_back({ templatePath / "config.make", projectDir / "config.make" }); } - -bool xcodeProject::loadProjectFile(){ //base +bool xcodeProject::loadProjectFile() { //base addCommand("# ---- PG VERSION " + getPGVersion()); addCommand("Add :_OFProjectGeneratorVersion string " + getPGVersion()); @@ -230,59 +216,55 @@ bool xcodeProject::loadProjectFile(){ //base } // FIXME: mover pra dentro do loadProjectfile -void xcodeProject::renameProject(){ //base +void xcodeProject::renameProject() { //base // FIXME: review BUILT_PRODUCTS_DIR - addCommand("Set :objects:"+buildConfigurationListUUID+":name " + projectName); + addCommand("Set :objects:" + buildConfigurationListUUID + ":name " + projectName); // Just OSX here, debug app naming. - if( target == "osx" ){ + if (target == "osx") { // TODO: Hardcode to variable // FIXME: Debug needed in name? addCommand("Set :objects:E4B69B5B0A3A1756003C02F2:path " + projectName + "Debug.app"); } } -fs::path getPathTo(fs::path path, string limit){ +fs::path getPathTo(fs::path path, string limit) { fs::path p; - vector folders = std::vector(path.begin(), path.end()); - for(auto & f: folders){ + vector folders = std::vector(path.begin(), path.end()); + for (auto & f : folders) { p /= f; - if(f.string() == limit){ -// alert("getPathTo "+ p.string(), 33); + if (f.string() == limit) { + // alert("getPathTo "+ p.string(), 33); return p; } } return p; } +string xcodeProject::getFolderUUID(const fs::path & folder, fs::path base) { //, bool isFolder, fs::path base) { + // alert ("xcodeProject::getFolderUUID "+folder.string());//+" : isfolder="+ofToString(isFolder)+" : base="+ base.string()); - -string xcodeProject::getFolderUUID(const fs::path & folder, fs::path base){//, bool isFolder, fs::path base) { -// alert ("xcodeProject::getFolderUUID "+folder.string());//+" : isfolder="+ofToString(isFolder)+" : base="+ base.string()); - -// TODO: Change key of folderUUID to base + folder, so "src" in additional source folders -// doesn't get confused with "src" from project. -// this can work but fullPath variable has to follow the same pattern + // TODO: Change key of folderUUID to base + folder, so "src" in additional source folders + // doesn't get confused with "src" from project. + // this can work but fullPath variable has to follow the same pattern auto fullPathFolder = folder; // If folder UUID exists just return it. - if ( folderUUID.find(fullPathFolder) != folderUUID.end() ) { // NOT FOUND + if (folderUUID.find(fullPathFolder) != folderUUID.end()) { // NOT FOUND return folderUUID[fullPathFolder]; - } - else { + } else { // in this case it is not found, so it creates UUID for the entire path - vector folders = std::vector(folder.begin(), folder.end()); + vector folders = std::vector(folder.begin(), folder.end()); string lastFolderUUID = projRootUUID; string lastFolder = ""; - if (folders.size()){ + if (folders.size()) { // Iterating every folder from full path - for (std::size_t a = 0; a < folders.size(); a++) { - fs::path fullPath{""}; + fs::path fullPath { "" }; std::vector joinFolders; joinFolders.reserve(a + 1); // Reserve / avoid reallocations @@ -291,14 +273,14 @@ string xcodeProject::getFolderUUID(const fs::path & folder, fs::path base){//, b joinFolders.push_back(folders[i]); } - for (const auto& j : joinFolders) { + for (const auto & j : joinFolders) { fullPath /= j; } -// alert("xcodeProject::getFolderUUID fullpath: " + fullPath.string(),33); + // alert("xcodeProject::getFolderUUID fullpath: " + fullPath.string(),33); // Query if partial path is already stored. if not execute this following block - if ( folderUUID.find(fullPath) != folderUUID.end() ) { + if (folderUUID.find(fullPath) != folderUUID.end()) { lastFolderUUID = folderUUID[fullPath]; lastFolder = ofPathToString(folderFromUUID[lastFolderUUID]); } @@ -311,87 +293,83 @@ string xcodeProject::getFolderUUID(const fs::path & folder, fs::path base){//, b addCommand(""); string folderName = ofPathToString(folders[a]); - addCommand("Add :objects:"+thisUUID+":name string " + folderName); + addCommand("Add :objects:" + thisUUID + ":name string " + folderName); // FIXME: Inspect if this is really being used -// if (isFolder) { -// alert("getFolderUUID, isFolder INSIDE " , 31); -// fs::path filePath; -// fs::path filePath_full { relRoot / fullPath }; -// // FIXME: known issue: doesn't handle files with spaces in name. -// -// if (fs::exists(filePath_full)) { -// filePath = filePath_full; -// } -// if (fs::exists(fullPath)) { -// filePath = fullPath; -// } -// -// if (!filePath.empty()) { -// addCommand("Add :objects:"+thisUUID+":path string " + ofPathToString(filePath)); -// } else { -// } -// } else { -//// alert("getFolderUUID isFolder false", 31); -// } - - addCommand("Add :objects:"+thisUUID+":isa string PBXGroup"); - + // if (isFolder) { + // alert("getFolderUUID, isFolder INSIDE " , 31); + // fs::path filePath; + // fs::path filePath_full { relRoot / fullPath }; + // // FIXME: known issue: doesn't handle files with spaces in name. + // + // if (fs::exists(filePath_full)) { + // filePath = filePath_full; + // } + // if (fs::exists(fullPath)) { + // filePath = fullPath; + // } + // + // if (!filePath.empty()) { + // addCommand("Add :objects:"+thisUUID+":path string " + ofPathToString(filePath)); + // } else { + // } + // } else { + //// alert("getFolderUUID isFolder false", 31); + // } + + addCommand("Add :objects:" + thisUUID + ":isa string PBXGroup"); bool bFolderPathSet = false; if (folderName == "external_sources" || folderName == "local_addons") { - addCommand("Add :objects:"+thisUUID+":sourceTree string SOURCE_ROOT"); - addCommand("Add :objects:"+thisUUID+":path string "); + addCommand("Add :objects:" + thisUUID + ":sourceTree string SOURCE_ROOT"); + addCommand("Add :objects:" + thisUUID + ":path string "); bFolderPathSet = true; - } - else { - if (lastFolderUUID == projRootUUID ){//} || + } else { + if (lastFolderUUID == projRootUUID) { //} || // lastFolder == "external_sources" || lastFolder == "local_addons") { // - - // Base folders can be in a different depth, // so we cut folders to point to the right path // ROY: THIS hardly makes sense to me. I can see the purpose of it. base2 is never set to anything. fs::path base2 { "" }; - size_t diff = folders.size() - (a+1); - for (size_t x=0; x"); -// fs::path addonFolder { fs::path(fullPath).filename() }; - addCommand("Add :objects:"+thisUUID+":path string " + ofPathToString(fullPath.filename())); + addCommand("Add :objects:" + thisUUID + ":sourceTree string "); + // fs::path addonFolder { fs::path(fullPath).filename() }; + addCommand("Add :objects:" + thisUUID + ":path string " + ofPathToString(fullPath.filename())); bFolderPathSet = true; } } - addCommand("Add :objects:"+thisUUID+":children array"); + addCommand("Add :objects:" + thisUUID + ":children array"); - if(!bFolderPathSet){ - if (folder.begin()->string() == "addons" || folder.begin()->string() == "src"){//} || folder.begin()->string() == "local_addons") { - addCommand("Add :objects:"+thisUUID+":sourceTree string "); + if (!bFolderPathSet) { + if (folder.begin()->string() == "addons" || folder.begin()->string() == "src") { //} || folder.begin()->string() == "local_addons") { + addCommand("Add :objects:" + thisUUID + ":sourceTree string "); // fs::path addonFolder { fs::path(fullPath).filename() }; - addCommand("Add :objects:"+thisUUID+":path string " + ofPathToString(fullPath.filename())); + addCommand("Add :objects:" + thisUUID + ":path string " + ofPathToString(fullPath.filename())); // alert ("group " + folder.string() + " : " + base.string() + " : " + addonFolder.string(), 32); } else { - addCommand("Add :objects:"+thisUUID+":sourceTree string SOURCE_ROOT"); + addCommand("Add :objects:" + thisUUID + ":sourceTree string SOURCE_ROOT"); } } // Add this new folder to its parent, projRootUUID if root - addCommand("Add :objects:"+lastFolderUUID+":children: string " + thisUUID); + addCommand("Add :objects:" + lastFolderUUID + ":children: string " + thisUUID); // keep this UUID as parent for the next folder. lastFolderUUID = thisUUID; @@ -403,77 +381,64 @@ string xcodeProject::getFolderUUID(const fs::path & folder, fs::path base){//, b } } -void xcodeProject::addSrc(const fs::path & srcFile, const fs::path & folder, SrcType type){ -// alert ("xcodeProject::addSrc " + ofPathToString(srcFile) + " : " + ofPathToString(folder), 31); +void xcodeProject::addSrc(const fs::path & srcFile, const fs::path & folder, SrcType type) { + // alert ("xcodeProject::addSrc " + ofPathToString(srcFile) + " : " + ofPathToString(folder), 31); string ext = ofPathToString(srcFile.extension()); -// .reference = true, -// .addToBuildPhase = true, -// .codeSignOnCopy = false, -// .copyFilesBuildPhase = false, -// .linkBinaryWithLibraries = false, -// .addToBuildResource = false, -// .addToResources = false, + // .reference = true, + // .addToBuildPhase = true, + // .codeSignOnCopy = false, + // .copyFilesBuildPhase = false, + // .linkBinaryWithLibraries = false, + // .addToBuildResource = false, + // .addToResources = false, fileProperties fp; fp.addToBuildPhase = true; fp.isSrc = true; -if( type == DEFAULT ){ - - if (ext == ".h" || ext == ".hpp"){ - fp.addToBuildPhase = false; - } - else if (ext == ".xib"){ - fp.addToBuildPhase = false; - fp.addToBuildResource = true; - fp.addToResources = true; - } - else if (ext == ".metal"){ - fp.addToBuildResource = true; - fp.addToResources = true; - } - else if(ext == ".entitlements"){ - fp.addToBuildResource = true; - fp.addToResources = true; - } - else if(ext == ".info"){ - fp.addToBuildResource = true; - fp.addToResources = true; - } - else if( ext == ".storyboard" ){ - fp.addToBuildPhase = false; - fp.copyBundleResources = true; - } - else if( ext == ".plist" ){ - fp.addToBuildPhase = true; - fp.copyBundleResources = true; - } - else if (ext == ".swift"){ - fp.addToBuildPhase = true; - for (auto &c : buildConfigs) { - addCommand("Add :objects:" + c + ":buildSettings:OTHER_SWIFT_FLAGS: string " + "-cxx-interoperability-mode=swift-5.9"); - // mark all Swift files as C++ interop available :) + if (type == DEFAULT) { + + if (ext == ".h" || ext == ".hpp") { + fp.addToBuildPhase = false; + } else if (ext == ".xib") { + fp.addToBuildPhase = false; + fp.addToBuildResource = true; + fp.addToResources = true; + } else if (ext == ".metal") { + fp.addToBuildResource = true; + fp.addToResources = true; + } else if (ext == ".entitlements") { + fp.addToBuildResource = true; + fp.addToResources = true; + } else if (ext == ".info") { + fp.addToBuildResource = true; + fp.addToResources = true; + } else if (ext == ".storyboard") { + fp.addToBuildPhase = false; + fp.copyBundleResources = true; + } else if (ext == ".plist") { + fp.addToBuildPhase = true; + fp.copyBundleResources = true; + } else if (ext == ".swift") { + fp.addToBuildPhase = true; + for (auto & c : buildConfigs) { + addCommand("Add :objects:" + c + ":buildSettings:OTHER_SWIFT_FLAGS: string " + "-cxx-interoperability-mode=swift-5.9"); + // mark all Swift files as C++ interop available :) + } + } else if (ext == ".xcassets") { + fp.addToBuildResource = true; + fp.addToResources = true; + } else if (ext == ".modulemap") { + fp.addToBuildPhase = false; + } else if (ext == ".bundle") { + fp.addToBuildResource = true; + fp.addToResources = true; + } else if (ext == ".tbd") { + fp.linkBinaryWithLibraries = true; } } - else if (ext == ".xcassets"){ - fp.addToBuildResource = true; - fp.addToResources = true; - } - else if (ext == ".modulemap") { - fp.addToBuildPhase = false; - } - else if (ext == ".bundle") { - fp.addToBuildResource = true; - fp.addToResources = true; - } - else if (ext == ".tbd") { - fp.linkBinaryWithLibraries = true; - } - - -} string UUID { addFile(srcFile, folder, fp) }; @@ -492,30 +457,29 @@ void xcodeProject::addCompileFlagsForMMFile(const fs::path & srcFile) { std::ifstream file(srcFile); if (!file.is_open()) return; - bool requiresNoARC = false; + bool requiresNoARC = false; - // Named regex for detecting ARC-related function calls in Objective-C++ - const std::regex arcFunctionRegex(R"(\b(alloc|dealloc|retain|release|autorelease)\b)"); + // Named regex for detecting ARC-related function calls in Objective-C++ + const std::regex arcFunctionRegex(R"(\b(alloc|dealloc|retain|release|autorelease)\b)"); - for (std::string line; std::getline(file, line); ) { - if (std::regex_search(line, arcFunctionRegex)) { - requiresNoARC = true; - break; - } + for (std::string line; std::getline(file, line);) { + if (std::regex_search(line, arcFunctionRegex)) { + requiresNoARC = true; + break; } + } - // Tag file as Objective-C++ in Xcode build settings - for (auto & c : buildConfigs) { -// addCommand("Add :objects:" + c + ":buildSettings:OTHER_CPLUSPLUSFLAGS: string " + "-xobjective-c++"); - -// if (requiresNoARC) { -// addCommand("Add :objects:" + c + ":buildSettings:OTHER_CPLUSPLUSFLAGS: string " + "-fno-objc-arc"); -// } - } + // Tag file as Objective-C++ in Xcode build settings + for (auto & c : buildConfigs) { + // addCommand("Add :objects:" + c + ":buildSettings:OTHER_CPLUSPLUSFLAGS: string " + "-xobjective-c++"); + // if (requiresNoARC) { + // addCommand("Add :objects:" + c + ":buildSettings:OTHER_CPLUSPLUSFLAGS: string " + "-fno-objc-arc"); + // } + } } -bool xcodeProject::containsObjectiveCPlusPlus(const fs::path &filePath) { +bool xcodeProject::containsObjectiveCPlusPlus(const fs::path & filePath) { std::ifstream file(filePath); if (!file.is_open()) return false; @@ -525,8 +489,8 @@ bool xcodeProject::containsObjectiveCPlusPlus(const fs::path &filePath) { "@synthesize", "@end" }; - for (std::string line; std::getline(file, line); ) { - for (const auto &keyword : objcKeywords) { + for (std::string line; std::getline(file, line);) { + for (const auto & keyword : objcKeywords) { if (line.find(keyword) != std::string::npos) { return true; } @@ -535,10 +499,8 @@ bool xcodeProject::containsObjectiveCPlusPlus(const fs::path &filePath) { return false; } - -void xcodeProject::addFramework(const fs::path & path, const fs::path & folder, bool isRelativeToSDK){ +void xcodeProject::addFramework(const fs::path & path, const fs::path & folder, bool isRelativeToSDK) { ofLogVerbose() << "Adding framework " << ofPathToString(path) << " folder: " << folder; -// alert( "xcodeProject::addFramework " + ofPathToString(path) + " : " + ofPathToString(folder) , 33); // path = the full path (w name) of this framework // folder = the path in the addon (in case we want to add this to the file browser -- we don't do that for system libs); @@ -549,11 +511,11 @@ void xcodeProject::addFramework(const fs::path & path, const fs::path & folder, fp.codeSignOnCopy = !isRelativeToSDK; fp.copyFilesBuildPhase = !isRelativeToSDK; fp.isRelativeToSDK = isRelativeToSDK; - fp.frameworksBuildPhase = !folder.empty(); + fp.linkBinaryWithLibraries = !folder.empty(); string UUID; if (isRelativeToSDK) { - fs::path frameworkPath { "System/Library/Frameworks/" + ofPathToString(path) + ".framework" } ; + fs::path frameworkPath { "System/Library/Frameworks/" + ofPathToString(path) + ".framework" }; UUID = addFile(frameworkPath, "Frameworks", fp); } else { UUID = addFile(path, folder, fp); @@ -568,15 +530,13 @@ void xcodeProject::addFramework(const fs::path & path, const fs::path & folder, addCommand("Add :objects:" + c + ":buildSettings:FRAMEWORK_SEARCH_PATHS: string " + parent); } if (path.extension() == ".xcframework") { - fp.addToBuildPhase = true; addCommand("Add :objects:" + c + ":buildSettings:XCFRAMEWORK_SEARCH_PATHS: string " + parent); } } } } - -void xcodeProject::addDylib(const fs::path & path, const fs::path & folder){ +void xcodeProject::addDylib(const fs::path & path, const fs::path & folder) { // alert( "xcodeProject::addDylib " + ofPathToString(path) , 33); // path = the full path (w name) of this framework @@ -590,72 +550,70 @@ void xcodeProject::addDylib(const fs::path & path, const fs::path & folder){ addFile(path, folder, fp); } - -void xcodeProject::addInclude(const fs::path & includeName){ +void xcodeProject::addInclude(const fs::path & includeName) { for (auto & c : buildConfigs) { - addCommand("Add :objects:"+c+":buildSettings:HEADER_SEARCH_PATHS: string " + ofPathToString(includeName)); + addCommand("Add :objects:" + c + ":buildSettings:HEADER_SEARCH_PATHS: string " + ofPathToString(includeName)); } } -void xcodeProject::addLibrary(const LibraryBinary & lib){ +void xcodeProject::addLibrary(const LibraryBinary & lib) { for (auto & c : buildConfigs) { - addCommand("Add :objects:"+c+":buildSettings:OTHER_LDFLAGS: string " + ofPathToString(fs::relative(lib.path))); + addCommand("Add :objects:" + c + ":buildSettings:OTHER_LDFLAGS: string " + ofPathToString(fs::relative(lib.path))); } } -void xcodeProject::addLDFLAG(const string& ldflag, LibType libType){ +void xcodeProject::addLDFLAG(const string & ldflag, LibType libType) { ofLogVerbose("xcodeProject::addLDFLAG") << ldflag; for (auto & c : buildConfigs) { - addCommand("Add :objects:"+c+":buildSettings:OTHER_LDFLAGS: string " + ldflag); + addCommand("Add :objects:" + c + ":buildSettings:OTHER_LDFLAGS: string " + ldflag); } } -void xcodeProject::addCFLAG(const string& cflag, LibType libType){ +void xcodeProject::addCFLAG(const string & cflag, LibType libType) { ofLogVerbose("xcodeProject::addCFLAG") << cflag; for (auto & c : buildConfigs) { // FIXME: add array here if it doesnt exist - addCommand("Add :objects:"+c+":buildSettings:OTHER_CFLAGS: string " + cflag); + addCommand("Add :objects:" + c + ":buildSettings:OTHER_CFLAGS: string " + cflag); } } -void xcodeProject::addDefine(const string& define, LibType libType){ +void xcodeProject::addDefine(const string & define, LibType libType) { for (auto & c : buildConfigs) { // FIXME: add array here if it doesnt exist - addCommand("Add :objects:"+c+":buildSettings:GCC_PREPROCESSOR_DEFINITIONS: string " + define); + addCommand("Add :objects:" + c + ":buildSettings:GCC_PREPROCESSOR_DEFINITIONS: string " + define); } } // FIXME: libtype is unused here -void xcodeProject::addCPPFLAG(const string& cppflag, LibType libType){ +void xcodeProject::addCPPFLAG(const string & cppflag, LibType libType) { for (auto & c : buildConfigs) { // FIXME: add array here if it doesnt exist - addCommand("Add :objects:"+c+":buildSettings:OTHER_CPLUSPLUSFLAGS: string " + cppflag); + addCommand("Add :objects:" + c + ":buildSettings:OTHER_CPLUSPLUSFLAGS: string " + cppflag); } } -void xcodeProject::addAfterRule(const string& rule){ +void xcodeProject::addAfterRule(const string & rule) { // return; -// cout << ">>>>>> addAfterRule " << rule << endl; - addCommand("Add :objects:"+afterPhaseUUID+":buildActionMask string 2147483647"); + // cout << ">>>>>> addAfterRule " << rule << endl; + addCommand("Add :objects:" + afterPhaseUUID + ":buildActionMask string 2147483647"); // addCommand("Add :objects:"+afterPhaseUUID+":files array"); // addCommand("Add :objects:"+afterPhaseUUID+":inputPaths array"); - addCommand("Add :objects:"+afterPhaseUUID+":isa string PBXShellScriptBuildPhase"); + addCommand("Add :objects:" + afterPhaseUUID + ":isa string PBXShellScriptBuildPhase"); // addCommand("Add :objects:"+afterPhaseUUID+":outputPaths array"); - addCommand("Add :objects:"+afterPhaseUUID+":runOnlyForDeploymentPostprocessing string 0"); - addCommand("Add :objects:"+afterPhaseUUID+":shellPath string /bin/sh"); - addCommand("Add :objects:"+afterPhaseUUID+":showEnvVarsInLog string 0"); + addCommand("Add :objects:" + afterPhaseUUID + ":runOnlyForDeploymentPostprocessing string 0"); + addCommand("Add :objects:" + afterPhaseUUID + ":shellPath string /bin/sh"); + addCommand("Add :objects:" + afterPhaseUUID + ":showEnvVarsInLog string 0"); // ofStringReplace(rule, "\"", "\\\""); // addCommand("Add :objects:"+afterPhaseUUID+":shellScript string \"" + rule + "\""); - addCommand("Add :objects:"+afterPhaseUUID+":shellScript string " + rule); + addCommand("Add :objects:" + afterPhaseUUID + ":shellScript string " + rule); // adding this phase to build phases array // TODO: Check if nit needs another buildConfigurationListUUID for debug. - addCommand("Add :objects:"+buildConfigurationListUUID+":buildPhases: string " + afterPhaseUUID); + addCommand("Add :objects:" + buildConfigurationListUUID + ":buildPhases: string " + afterPhaseUUID); } - -void xcodeProject::addAddonLibs(const ofAddon& addon){ +void xcodeProject::addAddonLibs(const ofAddon & addon) { for (auto & e : addon.libs) { ofLogVerbose() << "adding addon libs: " << e.path; addLibrary(e); @@ -665,62 +623,61 @@ void xcodeProject::addAddonLibs(const ofAddon& addon){ // cout << "dylibPath " << dylibPath << endl; if (dylibPath.extension() == ".dylib") { - if(addon.filesToFolders.find(dylibPath) == addon.filesToFolders.end()) { + if (addon.filesToFolders.find(dylibPath) == addon.filesToFolders.end()) { addDylib(dylibPath, dylibPath.parent_path().lexically_relative(addon.pathToOF)); - }else{ - addDylib(dylibPath,addon.filesToFolders.at(dylibPath)); + } else { + addDylib(dylibPath, addon.filesToFolders.at(dylibPath)); } } } } -void xcodeProject::addAddonSrcFiles(ofAddon& addon){ +void xcodeProject::addAddonSrcFiles(ofAddon & addon) { std::sort(addon.srcFiles.begin(), addon.srcFiles.end(), [](const fs::path & a, const fs::path & b) { return a.string() < b.string(); }); for (auto & e : addon.srcFiles) { ofLogVerbose() << "adding addon srcFiles: " << e; - if(addon.filesToFolders.find(e) == addon.filesToFolders.end()) { + if (addon.filesToFolders.find(e) == addon.filesToFolders.end()) { - addSrc(e,""); - }else{ - addSrc(e,addon.filesToFolders.at(e)); + addSrc(e, ""); + } else { + addSrc(e, addon.filesToFolders.at(e)); } } } //----------------------------------------------------------------------------------------------- -void xcodeProject::addAddonFrameworks(const ofAddon& addon){ +void xcodeProject::addAddonFrameworks(const ofAddon & addon) { ofLogVerbose("xcodeProject::addAddonFrameworks") << addon.name; - std::vector allFrameworks; - - allFrameworks.reserve( addon.frameworks.size() + addon.xcframeworks.size() ); - allFrameworks.insert( allFrameworks.end(), addon.frameworks.begin(), addon.frameworks.end() ); - allFrameworks.insert( allFrameworks.end(), addon.xcframeworks.begin(), addon.xcframeworks.end() ); + std::vector allFrameworks; + + allFrameworks.reserve(addon.frameworks.size() + addon.xcframeworks.size()); + allFrameworks.insert(allFrameworks.end(), addon.frameworks.begin(), addon.frameworks.end()); + allFrameworks.insert(allFrameworks.end(), addon.xcframeworks.begin(), addon.xcframeworks.end()); for (auto & f : allFrameworks) { -// for (auto & f : addon.frameworks) { + // for (auto & f : addon.frameworks) { ofLogVerbose() << "adding addon frameworks: " << f; -// alert ("ADD ADDON FRAMEWORKS " + f, 33); + // alert ("ADD ADDON FRAMEWORKS " + f, 33); auto path = f; // The only addon I've found using fixed path to system Frameworks is ofxCoreLocation // https://github.com/robotconscience/ofxCoreLocation/blob/533ee4b0d380a4a1aafbe1c5923ae66c26b92d53/addon_config.mk#L32 - if (ofIsStringInString(f, "/System/Library/Frameworks")){ + if (ofIsStringInString(f, "/System/Library/Frameworks")) { fs::path fullPath = f; path = ofPathToString(fullPath.filename()); } bool isRelativeToSDK = false; - size_t found=path.find('/'); - if (found==string::npos) { + size_t found = path.find('/'); + if (found == string::npos) { isRelativeToSDK = true; } fs::path folder = isRelativeToSDK ? "Frameworks" : addon.filesToFolders.at(f); addFramework(path, folder, isRelativeToSDK); - } } @@ -728,19 +685,18 @@ void xcodeProject::addAddonFrameworks(const ofAddon& addon){ string xcodeProject::addFile(const fs::path & path, const fs::path & folder, const fileProperties & fp) { string UUID { "" }; -// cout << "will check if exists " << (projectDir / path) << endl; -// if (fs::exists( projectDir / path )) + // cout << "will check if exists " << (projectDir / path) << endl; + // if (fs::exists( projectDir / path )) { -// cout << "OK exists" << endl; -// bool isFolder = false; + // cout << "OK exists" << endl; + // bool isFolder = false; string fileType { "file" }; fileType = extensionToFileType[path.extension()]; - if (fileType == "") { if (fs::is_directory(path) || fp.isGroupWithoutFolder) { fileType = "folder"; -// isFolder = true; + // isFolder = true; } else { // Break here if fileType is not set. and it is not a folder return {}; @@ -754,150 +710,151 @@ string xcodeProject::addFile(const fs::path & path, const fs::path & folder, con // encoding may be messing up for frameworks... so I switched to a pbx file ref without encoding fields -// if (fp.reference) { -// } else { -// addCommand("Add :objects:"+UUID+":isa string PBXGroup"); -// } + // if (fp.reference) { + // } else { + // addCommand("Add :objects:"+UUID+":isa string PBXGroup"); + // } // This is adding a file. any file. - addCommand("Add :objects:"+UUID+":fileEncoding string 4"); + addCommand("Add :objects:" + UUID + ":fileEncoding string 4"); if (fp.isGroupWithoutFolder) { - addCommand("Add :objects:"+UUID+":isa string PBXGroup"); + addCommand("Add :objects:" + UUID + ":isa string PBXGroup"); } else { - addCommand("Add :objects:"+UUID+":isa string PBXFileReference"); + addCommand("Add :objects:" + UUID + ":isa string PBXFileReference"); } - addCommand("Add :objects:"+UUID+":lastKnownFileType string " + fileType); - addCommand("Add :objects:"+UUID+":name string " + ofPathToString(path.filename())); + addCommand("Add :objects:" + UUID + ":lastKnownFileType string " + fileType); + addCommand("Add :objects:" + UUID + ":name string " + ofPathToString(path.filename())); if (fp.absolute) { - addCommand("Add :objects:"+UUID+":sourceTree string SOURCE_ROOT"); - if (fs::exists( projectDir / path )) { - addCommand("Add :objects:"+UUID+":path string " + ofPathToString(path)); + addCommand("Add :objects:" + UUID + ":sourceTree string SOURCE_ROOT"); + if (fs::exists(projectDir / path)) { + addCommand("Add :objects:" + UUID + ":path string " + ofPathToString(path)); } } else { - if(folder.begin()->string() == "local_addons" || folder.begin()->string() == "external_sources"){ -// if(path.is_absolute()){ - addCommand("Add :objects:"+UUID+":path string " + ofPathToString(path)); - addCommand("Add :objects:"+UUID+":sourceTree string SOURCE_ROOT"); -// }else{ -// if (fs::exists( projectDir / path )) { -// addCommand("Add :objects:"+UUID+":path string " + ofPathToString(projectDir /path)); -// } -// } + if (folder.begin()->string() == "local_addons" || folder.begin()->string() == "external_sources") { + // if(path.is_absolute()){ + addCommand("Add :objects:" + UUID + ":path string " + ofPathToString(path)); + addCommand("Add :objects:" + UUID + ":sourceTree string SOURCE_ROOT"); + // }else{ + // if (fs::exists( projectDir / path )) { + // addCommand("Add :objects:"+UUID+":path string " + ofPathToString(projectDir /path)); + // } + // } } else { if (fp.isRelativeToSDK) { - addCommand("Add :objects:"+UUID+":path string " + ofPathToString(path)); - addCommand("Add :objects:"+UUID+":sourceTree string SDKROOT"); + addCommand("Add :objects:" + UUID + ":path string " + ofPathToString(path)); + addCommand("Add :objects:" + UUID + ":sourceTree string SDKROOT"); } else { - addCommand("Add :objects:"+UUID+":sourceTree string "); + addCommand("Add :objects:" + UUID + ":sourceTree string "); } } } -// string folderUUID; -// auto rootDir = folder.root_directory(); -// if (rootDir != "addons" && rootDir != "src") { -//// alert("addFile path:" + ofPathToString(path) + " folder:" + ofPathToString(folder) , 31); -// auto base = path.parent_path(); -// folderUUID = getFolderUUID(folder, isFolder, base); -// -// } else { -// folderUUID = getFolderUUID(folder, isFolder); -// } + // string folderUUID; + // auto rootDir = folder.root_directory(); + // if (rootDir != "addons" && rootDir != "src") { + //// alert("addFile path:" + ofPathToString(path) + " folder:" + ofPathToString(folder) , 31); + // auto base = path.parent_path(); + // folderUUID = getFolderUUID(folder, isFolder, base); + // + // } else { + // folderUUID = getFolderUUID(folder, isFolder); + // } // Eventually remove isFolder and base parameter - std::string folderUUID { getFolderUUID(folder, path)}; + std::string folderUUID { getFolderUUID(folder, path) }; //, isFolder) }; - addCommand("# ---- addFileToFolder UUID : " + ofPathToString(folder)); addCommand("Add :objects:" + folderUUID + ":children: string " + UUID); string buildUUID { generateUUID(ofPathToString(path) + "-build") }; // If any other option is true, add buildUUID entries. if ( - fp.addToBuildPhase || - fp.codeSignOnCopy || - fp.copyFilesBuildPhase || - fp.addToBuildResource || - fp.addToResources || - fp.copyBundleResources - //|| fp.frameworksBuildPhase ~ I've just removed this one, favoring -InFrameworks - ) { - addCommand("# ---- addToBuildPhase " + buildUUID); - addCommand("Add :objects:"+buildUUID+":isa string PBXBuildFile"); - addCommand("Add :objects:"+buildUUID+":fileRef string "+UUID); + fp.addToBuildPhase || fp.codeSignOnCopy || fp.copyFilesBuildPhase || fp.addToBuildResource || fp.addToResources || fp.copyBundleResources + ) { + addCommand("# ---- addFileToBuildUUID " + buildUUID); + addCommand("Add :objects:" + buildUUID + ":isa string PBXBuildFile"); + addCommand("Add :objects:" + buildUUID + ":fileRef string " + UUID); } if (fp.addToBuildPhase) { // Compile Sources // Not sure if it applies to everything, applies to srcFile. addCommand("# ---- addToBuildPhase"); - addCommand("Add :objects:"+buildActionMaskUUID+":files: string " + buildUUID); + addCommand("Add :objects:" + buildActionMaskUUID + ":files: string " + buildUUID); } - if (fp.copyBundleResources) { addCommand("# ---- copyBundleResources"); - addCommand("Add :objects:"+copyBundleResourcesUUID+":files: string " + buildUUID); - } - - if (fp.copyFilesBuildPhase) { - // If we are going to add xcframeworks to copy files -> destination frameworks, we should include here -// if (path.extension() == ".framework" || path.extension() == ".xcframework") { - // This now includes both .framework and .xcframework - if (fileType == "wrapper.framework" || fileType == ".xcframework") { - // copy to frameworks - addCommand("# ---- copyPhase Frameworks " + buildUUID); - addCommand("Add :objects:E4C2427710CC5ABF004149E2:files: string " + buildUUID); - } else { - // copy to executables - addCommand("# ---- copyPhase Executables " + buildUUID); - addCommand("Add :objects:E4A5B60F29BAAAE400C2D356:files: string " + buildUUID); - } - } + addCommand("Add :objects:" + copyBundleResourcesUUID + ":files: string " + buildUUID); + } + +// if (fp.copyFilesBuildPhase) { +// // If we are going to add xcframeworks to copy files -> destination frameworks, we should include here +// // if (path.extension() == ".framework" || path.extension() == ".xcframework") { +// // This now includes both .framework and .xcframework +// if (fileType == "wrapper.framework" || fileType == ".xcframework") { +// // copy to frameworks +// addCommand("# ---- copyPhase Frameworks " + buildUUID); +// addCommand("Add :objects:E4C2427710CC5ABF004149E2:files: string " + buildUUID); +// } else { +// // copy to executables +// addCommand("# ---- copyPhase Executables " + buildUUID); +// addCommand("Add :objects:E4A5B60F29BAAAE400C2D356:files: string " + buildUUID); +// } +// } if (fp.codeSignOnCopy) { addCommand("# ---- codeSignOnCopy " + buildUUID); - addCommand("Add :objects:"+buildUUID+":settings:ATTRIBUTES array"); - addCommand("Add :objects:"+buildUUID+":settings:ATTRIBUTES: string CodeSignOnCopy"); + addCommand("Add :objects:" + buildUUID + ":settings:ATTRIBUTES array"); + addCommand("Add :objects:" + buildUUID + ":settings:ATTRIBUTES: string CodeSignOnCopy"); } if (fp.addToBuildResource) { string mediaAssetsUUID { "9936F60E1BFA4DEE00891288" }; addCommand("# ---- addToBuildResource"); - addCommand("Add :objects:"+mediaAssetsUUID+":files: string " + UUID); + addCommand("Add :objects:" + mediaAssetsUUID + ":files: string " + UUID); } if (fp.addToResources) { // FIXME: test if it is working on iOS if (resourcesUUID != "") { addCommand("# ---- addToResources (IOS only) ?" + buildUUID); - addCommand("Add :objects:"+resourcesUUID+": string " + buildUUID); + addCommand("Add :objects:" + resourcesUUID + ": string " + buildUUID); } } - if (fp.frameworksBuildPhase) { // Link Binary With Libraries - auto tempUUID = generateUUID(ofPathToString(path) + "-InFrameworks"); - addCommand("Add :objects:" + tempUUID + ":fileRef string " + UUID); - addCommand("Add :objects:" + tempUUID + ":isa string PBXBuildFile"); + // needed or the same? +// if (fp.linkBinaryWithLibraries) { // Link Binary With Libraries +// addCommand("# --- linkBinaryWithLibraries"); +// addCommand("Add :objects:" + uuidMap["linkBinaryWithLibraries"] + ":files: string " + buildUUID); +// alert (commands.back(), 95); +// } - addCommand("# --- PBXFrameworksBuildPhase"); - addCommand("Add :objects:E4B69B590A3A1756003C02F2:files: string " + tempUUID); - } +// if (fp.frameworksBuildPhase) { // Link Binary With Libraries + if (fp.linkBinaryWithLibraries) { // Link Binary With Libraries + auto tempUUID = generateUUID(ofPathToString(path) + "-InFrameworks"); + addCommand("Add :objects:" + tempUUID + ":fileRef string " + UUID); + addCommand("Add :objects:" + tempUUID + ":isa string PBXBuildFile"); + addCommand("# --- linkBinaryWithLibraries PBXFrameworksBuildPhase"); +// uuidMap["linkBinaryWithLibraries"] = "E4B69B590A3A1756003C02F2"; + addCommand("Add :objects:" + uuidMap["linkBinaryWithLibraries"] + ":files: string " + tempUUID); + alert (commands.back(), 96); + } - if (path.extension() == ".framework" || path.extension() == ".xcframework") { - addCommand("# ---- Frameworks Folder " + UUID); - addCommand("Add :objects:901808C02053638E004A7774:children: string " + UUID); - addCommand("# ---- PBXFrameworksBuildPhase " + buildUUID); - addCommand("Add :objects:1D60588F0D05DD3D006BFB54:files: string " + buildUUID); - } + // if ( path.extension() == ".framework" || path.extension() == ".xcframework" ) { + // addCommand("# ---- Frameworks Folder " + UUID); + // addCommand("Add :objects:901808C02053638E004A7774:children: string " + UUID); + +// addCommand("# ---- PBXFrameworksBuildPhase " + buildUUID); +// addCommand("Add :objects:1D60588F0D05DD3D006BFB54:files: string " + buildUUID); +// } } return UUID; } - void xcodeProject::addCommand(const string & command) { if (debugCommands) { alert(command, 31); @@ -905,28 +862,25 @@ void xcodeProject::addCommand(const string & command) { commands.emplace_back(command); } +bool xcodeProject::saveProjectFile() { -bool xcodeProject::saveProjectFile(){ - -// debugCommands = true; - + // debugCommands = true; fileProperties fp; -// fp.isGroupWithoutFolder = true; -// addFile("additionalSources", "", fp); -// fp.isGroupWithoutFolder = false; -// addFile("openFrameworks-Info.plist", "", fp); -// addFile("of.entitlements", "", fp); -// addFile("Project.xcconfig", "", fp); - if (fs::exists( projectDir / "App.xcconfig" )) { + // fp.isGroupWithoutFolder = true; + // addFile("additionalSources", "", fp); + // fp.isGroupWithoutFolder = false; + // addFile("openFrameworks-Info.plist", "", fp); + // addFile("of.entitlements", "", fp); + // addFile("Project.xcconfig", "", fp); + if (fs::exists(projectDir / "App.xcconfig")) { addFile("App.xcconfig", "", fp); } fp.absolute = true; -// addFile("../../../libs/openframeworks", "", fp); - addFile(fs::path{"bin"} / "data", "", fp); - + // addFile("../../../libs/openframeworks", "", fp); + addFile(fs::path { "bin" } / "data", "", fp); -// debugCommands = false; + // debugCommands = false; fs::path fileName { projectDir / (projectName + ".xcodeproj/project.pbxproj") }; bool usePlistBuddy = false; @@ -944,16 +898,16 @@ bool xcodeProject::saveProjectFile(){ // JSON Block - Multiplatform std::ifstream contents(fileName); -// std::cout << contents.rdbuf() << std::endl; + // std::cout << contents.rdbuf() << std::endl; json j; try { j = json::parse(contents); // Ugly hack to make nlohmann json work with v 3.11.3 -// auto dump = j.dump(1, ' '); -// if (dump[0] == '[') { -// j = j[0]; -// } + // auto dump = j.dump(1, ' '); + // if (dump[0] == '[') { + // j = j[0]; + // } } catch (json::parse_error & ex) { ofLogError(xcodeProject::LOG_NAME) << "JSON parse error at byte" << ex.byte; @@ -963,14 +917,14 @@ bool xcodeProject::saveProjectFile(){ contents.close(); for (auto & c : commands) { -// alert (c, 31); + // alert (c, 31); // readable comments enabled now. if (c != "" && c[0] != '#') { vector cols { ofSplitString(c, " ") }; string thispath { cols[1] }; ofStringReplace(thispath, ":", "/"); - if (thispath.substr(thispath.length() -1) != "/") { + if (thispath.substr(thispath.length() - 1) != "/") { //if (cols[0] == "Set") { try { json::json_pointer p { json::json_pointer(thispath) }; @@ -982,22 +936,20 @@ bool xcodeProject::saveProjectFile(){ j[p] = c.substr(stringStart); } catch (std::exception & e) { - ofLogError() << "substr " << c.substr(stringStart) << "\n" << - "pointer " << p << "\n" << - e.what(); + ofLogError() << "substr " << c.substr(stringStart) << "\n" + << "pointer " << p << "\n" + << e.what(); } // j[p] = cols[3]; - } - else if (cols[2] == "array") { + } else if (cols[2] == "array") { try { -// j[p] = {}; + // j[p] = {}; j[p] = json::array({}); } catch (std::exception & e) { ofLogError() << "array " << e.what(); } } - } - catch (std::exception & e) { + } catch (std::exception & e) { cout << "pointer " << thispath; ofLogError(xcodeProject::LOG_NAME) << "first json error "; ofLogError() << e.what(); @@ -1005,28 +957,26 @@ bool xcodeProject::saveProjectFile(){ ofLogError() << "-------------------------"; } - - } - else { - thispath = thispath.substr(0, thispath.length() -1); -// cout << thispath << endl; + } else { + thispath = thispath.substr(0, thispath.length() - 1); + // cout << thispath << endl; json::json_pointer p = json::json_pointer(thispath); try { // Fixing XCode one item array issue if (!j[p].is_array()) { -// cout << endl; -// alert (c, 31); -// cout << "this is not array, creating" << endl; -// cout << thispath << endl; + // cout << endl; + // alert (c, 31); + // cout << "this is not array, creating" << endl; + // cout << thispath << endl; auto v { j[p] }; j[p] = json::array(); if (!v.is_null()) { -// cout << "thispath " << thispath << endl; + // cout << "thispath " << thispath << endl; j[p].emplace_back(v); } } -// alert (c, 31); -// alert ("emplace back " + cols[3] , 32); + // alert (c, 31); + // alert ("emplace back " + cols[3] , 32); j[p].emplace_back(cols[3]); } catch (std::exception & e) { @@ -1036,11 +986,10 @@ bool xcodeProject::saveProjectFile(){ ofLogError() << "-------------------------"; } } -// alert("-----", 32); + // alert("-----", 32); } } - std::ofstream jsonFile(fileName); // This is not pretty but address some differences in nlohmann json 3.11.2 to 3.11.3 @@ -1051,16 +1000,16 @@ bool xcodeProject::saveProjectFile(){ try { jsonFile << dump; - } catch(std::exception & e) { + } catch (std::exception & e) { ofLogError("xcodeProject::saveProjectFile") << "Error saving json to " << fileName << ": " << e.what(); return false; - } catch(...) { + } catch (...) { ofLogError("xcodeProject::saveProjectFile") << "Error saving json to " << fileName; return false; } jsonFile.close(); } -// for (auto & c : commands) cout << c << endl; + // for (auto & c : commands) cout << c << endl; return true; } diff --git a/commandLine/src/projects/xcodeProject.h b/commandLine/src/projects/xcodeProject.h index c6c1a189..d8b61784 100644 --- a/commandLine/src/projects/xcodeProject.h +++ b/commandLine/src/projects/xcodeProject.h @@ -32,7 +32,7 @@ class xcodeProject : public baseProject { bool linkBinaryWithLibraries = false; bool addToBuildResource = false; bool addToResources = false; - bool frameworksBuildPhase = false; +// bool frameworksBuildPhase = false; bool isSrc = false; bool isGroupWithoutFolder = false; bool isRelativeToSDK = false; @@ -57,7 +57,7 @@ class xcodeProject : public baseProject { void addFramework(const fs::path & path, const fs::path & folder, bool isRelativeToSDK = false) override; void addXCFramework(const fs::path & path, const fs::path & folder); void addDylib(const fs::path & path, const fs::path & folder); - + bool containsObjectiveCPlusPlus(const fs::path &filePath); void saveScheme(); @@ -68,7 +68,7 @@ class xcodeProject : public baseProject { string projRootUUID; string resourcesUUID; - string frameworksUUID; +// string frameworksUUID; string copyBundleResourcesUUID; string afterPhaseUUID; string buildPhasesUUID; @@ -130,4 +130,7 @@ class xcodeProject : public baseProject { { ".storyboard" , "wrapper.storyboard" }, }; + // other uuid strings can be ported to here. + std::map uuidMap; + };