From b275ad1b844ac877f2552361505337ad4f206259 Mon Sep 17 00:00:00 2001 From: ofTheo Date: Thu, 9 Mar 2023 16:13:08 -0800 Subject: [PATCH] Add dylibs to copy build phase closes #320 --- .../src/projects/xcodeProject.cpp | 54 +++++++++++++++++++ .../src/projects/xcodeProject.h | 1 + 2 files changed, 55 insertions(+) diff --git a/ofxProjectGenerator/src/projects/xcodeProject.cpp b/ofxProjectGenerator/src/projects/xcodeProject.cpp index de949a1f..de875d5c 100644 --- a/ofxProjectGenerator/src/projects/xcodeProject.cpp +++ b/ofxProjectGenerator/src/projects/xcodeProject.cpp @@ -508,6 +508,57 @@ void xcodeProject::addFramework(string name, string path, string folder){ } } +void xcodeProject::addDylib(string name, string path){ + // name = name of the dylib + // 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); + + //----------------------------------------------------------------- + // based on the extension make some choices about what to do: + //----------------------------------------------------------------- + + //----------------------------------------------------------------- + // (A) make a FILE REF + //----------------------------------------------------------------- + + // encoding may be messing up for frameworks... so I switched to a pbx file ref without encoding fields + string UUID = generateUUID( name ); + + //commands.emplace_back("Add :objects:"+UUID+":fileEncoding string 4"); + commands.emplace_back("Add :objects:"+UUID+":path string "+path); + commands.emplace_back("Add :objects:"+UUID+":isa string PBXFileReference"); + commands.emplace_back("Add :objects:"+UUID+":name string "+name); + commands.emplace_back("Add :objects:"+UUID+":lastKnownFileType string compiled.mach-o.dylib"); + commands.emplace_back("Add :objects:"+UUID+":sourceTree string SOURCE_ROOT"); + + string buildUUID = generateUUID(name + "-build"); + commands.emplace_back("Add :objects:"+buildUUID+":isa string PBXBuildFile"); + commands.emplace_back("Add :objects:"+buildUUID+":fileRef string "+UUID); + + // new - code sign dylibs on copy + commands.emplace_back("Add :objects:"+buildUUID+":settings:ATTRIBUTES array"); + commands.emplace_back("Add :objects:"+buildUUID+":settings:ATTRIBUTES: string CodeSignOnCopy"); + +// // we add one of the build refs to the list of frameworks +// // TENTATIVA desesperada aqui... +// string folderUUID = getFolderUUID(folder); +// commands.emplace_back("Add :objects:"+folderUUID+":children: string " + UUID); + + string buildUUID2 = generateUUID(name + "-build2"); + commands.emplace_back("Add :objects:"+buildUUID2+":fileRef string "+UUID); + commands.emplace_back("Add :objects:"+buildUUID2+":isa string PBXBuildFile"); + + // new - code sign frameworks on copy + commands.emplace_back("Add :objects:"+buildUUID2+":settings:ATTRIBUTES array"); + commands.emplace_back("Add :objects:"+buildUUID2+":settings:ATTRIBUTES: string CodeSignOnCopy"); + + // UUID hardcoded para PBXCopyFilesBuildPhase + // FIXME: hardcoded - this is the same for the next fixme. so maybe a clearer ident can make things better here. + commands.emplace_back("Add :objects:E4A5B60F29BAAAE400C2D356:files: string " + buildUUID2); + +} + + void xcodeProject::addInclude(string includeName){ // @@ -612,6 +663,9 @@ void xcodeProject::addAddon(ofAddon & addon){ for(int i=0;i<(int)addon.libs.size();i++){ ofLogVerbose() << "adding addon libs: " << addon.libs[i].path; addLibrary(addon.libs[i]); + if( ofFilePath::getFileExt(addon.libs[i].path) == "dylib" ){ + addDylib( ofFilePath::getFileName(addon.libs[i].path), addon.libs[i].path); + } } for(int i=0;i<(int)addon.cflags.size();i++){ ofLogVerbose() << "adding addon cflags: " << addon.cflags[i]; diff --git a/ofxProjectGenerator/src/projects/xcodeProject.h b/ofxProjectGenerator/src/projects/xcodeProject.h index aac9ad03..58e86822 100644 --- a/ofxProjectGenerator/src/projects/xcodeProject.h +++ b/ofxProjectGenerator/src/projects/xcodeProject.h @@ -28,6 +28,7 @@ class xcodeProject : public baseProject { // macOS specific void addFramework(string name, string path, string folder=""); + void addDylib(string name, string path); void addAddon(ofAddon & addon); void saveScheme();