66#else
77 #include < nlohmann/json.hpp> // MSYS2 : use of system-installed include
88#endif
9+ #ifdef __APPLE__
10+ #include < cstdlib> // std::system
11+ #endif
912#include < iostream>
1013
1114using nlohmann::json;
@@ -134,10 +137,26 @@ bool xcodeProject::createProjectFile(){
134137 // originally only on IOS
135138 // this is needed for 0.9.3 / 0.9.4 projects which have iOS media assets in bin/data/
136139 // TODO: Test on IOS
140+ fs::path templateBinDir { templatePath / " bin" };
137141 fs::path templateDataDir { templatePath / " bin" / " data" };
138142 if (fs::exists (templateDataDir) && fs::is_directory (templateDataDir)) {
139143 baseProject::recursiveCopyContents (templateDataDir, projectDataDir);
140144 }
145+ if (fs::exists (templateBinDir) && fs::is_directory (templateBinDir)) {
146+ #ifdef __APPLE__
147+ try {
148+ // extended attributes on macOS
149+ std::string command = " xattr -w com.apple.xcode.CreatedByBuildSystem true " + templateBinDir.string ();
150+ if (std::system (command.c_str ()) != 0 ) {
151+ std::cerr << " Failed to set extended attributes on " << templateBinDir.string () << std::endl;
152+ } else {
153+ std::cout << " xattr set correctly for bin" << endl;
154+ }
155+ } catch (const std::exception& e) {
156+ std::cout << e.what () << std::endl;
157+ }
158+ #endif
159+ }
141160 }
142161
143162 return true ;
@@ -418,16 +437,11 @@ void xcodeProject::addXCFramework(const fs::path & path, const fs::path & folder
418437
419438 addCommand (" # ----- addXCFramework path=" + ofPathToString (path) + " folder=" + ofPathToString (folder));
420439
421- bool isSystemFramework = false ;
422- if (!folder.empty () && !ofIsStringInString (ofPathToString (path), " /System/Library/Frameworks" )
423- && target != " ios" ){
424- isSystemFramework = true ;
425- }
426440
427441 fileProperties fp;
428442// fp.addToBuildPhase = true;
429- fp.codeSignOnCopy = !isSystemFramework ;
430- fp.copyFilesBuildPhase = !isSystemFramework ;
443+ fp.codeSignOnCopy = true ;
444+ fp.copyFilesBuildPhase = true ;
431445 fp.frameworksBuildPhase = (target != " ios" && !folder.empty ());
432446
433447 string UUID {
@@ -438,7 +452,7 @@ void xcodeProject::addXCFramework(const fs::path & path, const fs::path & folder
438452 string parent { ofPathToString (path.parent_path ()) };
439453
440454 for (auto & c : buildConfigs) {
441- addCommand (" Add :objects:" + c + " :buildSettings:XFRAMEWORK_SEARCH_PATHS : string " + parent);
455+ addCommand (" Add :objects:" + c + " :buildSettings:XCFRAMEWORK_SEARCH_PATHS : string " + parent);
442456 }
443457}
444458
@@ -611,14 +625,13 @@ void xcodeProject::addAddon(ofAddon & addon){
611625 folder = addon.addonPath / " xcframeworks" ;
612626 }
613627 // MARK: Is this ok to call .framework?
614- addXCFramework (" /System/Library/Frameworks/" + f + " .framework " , folder);
628+ addXCFramework (" /System/Library/Frameworks/" + f + " .xcframework " , folder);
615629
616630 } else {
617631 if (ofIsStringInString (f, " /System/Library" )) {
618- addFramework (f, " addons/" + addon.name + " /frameworks" );
619-
632+ addXCFramework (f, " addons/" + addon.name + " /xcframeworks" );
620633 } else {
621- addFramework (f, addon.filesToFolders [f]);
634+ addXCFramework (f, addon.filesToFolders [f]);
622635 }
623636 }
624637 }
@@ -719,7 +732,10 @@ string xcodeProject::addFile(const fs::path & path, const fs::path & folder, con
719732 }
720733
721734 if (fp.copyFilesBuildPhase ) {
722- if (path.extension () == " .framework" ) {
735+ // If we are going to add xcframeworks to copy files -> destination frameworks, we should include here
736+ // if (path.extension() == ".framework" || path.extension() == ".xcframework") {
737+ // This now includes both .framework and .xcframework
738+ if (fileType == " wrapper.framework" || fileType == " .xcframework" ) {
723739 // copy to frameworks
724740 addCommand (" # ---- copyPhase Frameworks " + buildUUID);
725741 addCommand (" Add :objects:E4C2427710CC5ABF004149E2:files: string " + buildUUID);
@@ -784,7 +800,7 @@ bool xcodeProject::saveProjectFile(){
784800// debugCommands = true;
785801
786802 addCommand (" # ---- PG VERSION " + getPGVersion ());
787- addCommand (" Add :_openFrameworksProjectGeneratorVersion string " + getPGVersion ());
803+ addCommand (" Add :a_OFProjectGeneratorVersion string " + getPGVersion ());
788804
789805 fileProperties fp;
790806// fp.isGroupWithoutFolder = true;
0 commit comments