Skip to content

Commit c015e0d

Browse files
authored
Add dylibs to copy build phase closes #320 (#321)
1 parent ebeb73a commit c015e0d

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

ofxProjectGenerator/src/projects/xcodeProject.cpp

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,57 @@ void xcodeProject::addFramework(string name, string path, string folder){
503503
}
504504
}
505505

506+
void xcodeProject::addDylib(string name, string path){
507+
// name = name of the dylib
508+
// path = the full path (w name) of this framework
509+
// 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);
510+
511+
//-----------------------------------------------------------------
512+
// based on the extension make some choices about what to do:
513+
//-----------------------------------------------------------------
514+
515+
//-----------------------------------------------------------------
516+
// (A) make a FILE REF
517+
//-----------------------------------------------------------------
518+
519+
// encoding may be messing up for frameworks... so I switched to a pbx file ref without encoding fields
520+
string UUID = generateUUID( name );
521+
522+
//commands.emplace_back("Add :objects:"+UUID+":fileEncoding string 4");
523+
commands.emplace_back("Add :objects:"+UUID+":path string "+path);
524+
commands.emplace_back("Add :objects:"+UUID+":isa string PBXFileReference");
525+
commands.emplace_back("Add :objects:"+UUID+":name string "+name);
526+
commands.emplace_back("Add :objects:"+UUID+":lastKnownFileType string compiled.mach-o.dylib");
527+
commands.emplace_back("Add :objects:"+UUID+":sourceTree string SOURCE_ROOT");
528+
529+
string buildUUID = generateUUID(name + "-build");
530+
commands.emplace_back("Add :objects:"+buildUUID+":isa string PBXBuildFile");
531+
commands.emplace_back("Add :objects:"+buildUUID+":fileRef string "+UUID);
532+
533+
// new - code sign dylibs on copy
534+
commands.emplace_back("Add :objects:"+buildUUID+":settings:ATTRIBUTES array");
535+
commands.emplace_back("Add :objects:"+buildUUID+":settings:ATTRIBUTES: string CodeSignOnCopy");
536+
537+
// // we add one of the build refs to the list of frameworks
538+
// // TENTATIVA desesperada aqui...
539+
// string folderUUID = getFolderUUID(folder);
540+
// commands.emplace_back("Add :objects:"+folderUUID+":children: string " + UUID);
541+
542+
string buildUUID2 = generateUUID(name + "-build2");
543+
commands.emplace_back("Add :objects:"+buildUUID2+":fileRef string "+UUID);
544+
commands.emplace_back("Add :objects:"+buildUUID2+":isa string PBXBuildFile");
545+
546+
// new - code sign frameworks on copy
547+
commands.emplace_back("Add :objects:"+buildUUID2+":settings:ATTRIBUTES array");
548+
commands.emplace_back("Add :objects:"+buildUUID2+":settings:ATTRIBUTES: string CodeSignOnCopy");
549+
550+
// UUID hardcoded para PBXCopyFilesBuildPhase
551+
// FIXME: hardcoded - this is the same for the next fixme. so maybe a clearer ident can make things better here.
552+
commands.emplace_back("Add :objects:E4A5B60F29BAAAE400C2D356:files: string " + buildUUID2);
553+
554+
}
555+
556+
506557
void xcodeProject::addInclude(string includeName){
507558

508559
// string relRoot = getOFRelPathFS(projectDir).string();
@@ -602,6 +653,9 @@ void xcodeProject::addAddon(ofAddon & addon){
602653
for (auto & e : addon.libs) {
603654
ofLogVerbose() << "adding addon libs: " << e.path;
604655
addLibrary(e);
656+
if( ofFilePath::getFileExt(e.path) == "dylib" ){
657+
addDylib(ofFilePath::getFileName(e.path), e.path);
658+
}
605659
}
606660

607661
for (auto & e : addon.cflags) {

ofxProjectGenerator/src/projects/xcodeProject.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class xcodeProject : public baseProject {
2828

2929
// macOS specific
3030
void addFramework(string name, string path, string folder="");
31+
void addDylib(string name, string path);
3132

3233
void addAddon(ofAddon & addon);
3334
void saveScheme();

0 commit comments

Comments
 (0)