Skip to content

Commit 98920bc

Browse files
danoli3dimitre
andauthoredJun 8, 2024··
V46 XCFrameworks Fixing (#522)
* up * up * dan comments * v bump * Scripts fixing copying attributes of signing when we need it Fix not copying / removing built commandLine PG into app dir if exists / clean * Set to Utility for Apple * XCFrameworks fixing * Fixes for xattrib xcode bin clean issue --------- Co-authored-by: Dimitre <[email protected]>
1 parent 892affb commit 98920bc

File tree

6 files changed

+47
-21
lines changed

6 files changed

+47
-21
lines changed
 

‎commandLine/commandLine.xcodeproj/project.pbxproj

+2
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@
408408
src/uuidxx/license,
409409
src/uuidxx/src,
410410
);
411+
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
411412
LIBRARY_SEARCH_PATHS = "$(inherited)";
412413
ONLY_ACTIVE_ARCH = NO;
413414
OTHER_LDFLAGS = (
@@ -435,6 +436,7 @@
435436
src/uuidxx/license,
436437
src/uuidxx/src,
437438
);
439+
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
438440
LIBRARY_SEARCH_PATHS = "$(inherited)";
439441
ONLY_ACTIVE_ARCH = NO;
440442
OTHER_LDFLAGS = (

‎commandLine/src/projects/baseProject.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#define PG_VERSION "45"
3+
#define PG_VERSION "46"
44

55
#include "ofAddon.h"
66
#include "pugixml.hpp"

‎commandLine/src/projects/xcodeProject.cpp

+30-14
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
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

1114
using 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;

‎commandLine/src/projects/xcodeProject.h

+1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ class xcodeProject : public baseProject {
9898

9999
std::map<fs::path, string> extensionToFileType {
100100
{ ".framework" , "wrapper.framework" },
101+
{ ".xcframework" , "wrapper.xcframework" },
101102
{ ".dylib" , "compiled.mach-o.dylib" },
102103

103104
{ ".cpp" , "sourcecode.cpp.cpp" },

‎scripts/osx/build_frontend.sh

+12-5
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,21 @@ fi
2929
SOURCE_FILE="${PG_DIR}/commandLine/bin/projectGenerator"
3030

3131
# Replace [destination_path] with the actual path where you want to copy the file
32-
DESTINATION_PATH="app/"
32+
DESTINATION_PATH="app"
3333
echo "SOURCE_FILE:$SOURCE_FILE";
34+
35+
3436
# Check if the source file exists
3537
if [ -f "$SOURCE_FILE" ]; then
36-
# File exists, proceed with copying
37-
mkdir -p "$DESTINATION_PATH" # Create destination directory if it doesn't exist
38-
cp "$SOURCE_FILE" "$DESTINATION_PATH"
39-
echo "File copied successfully."
38+
echo "File exists, proceed with copying"
39+
echo "check destination:[$DESTINATION_PATH/projectGenerator]"
40+
if [ -f "${DESTINATION_PATH}/projectGenerator" ]; then
41+
echo "projectGenerator File exists at DESTINATION_PATH - rm old"
42+
rm -f "${DESTINATION_PATH}/projectGenerator"
43+
fi
44+
mkdir -p "$DESTINATION_PATH" # Create destination directory if it doesn't exist
45+
cp -X "$SOURCE_FILE" "$DESTINATION_PATH/"
46+
echo "File copied successfully."
4047
else
4148
# File does not exist
4249
echo "Error: Source file does not exist."

‎scripts/osx/ci_build_pg.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ package_app(){
4747
ls
4848
echo "-------------"
4949
#echo "copy cmdline PG to "
50-
cp commandLine/bin/projectGenerator projectGenerator-$PLATFORM/projectGenerator.app/Contents/Resources/app/app/projectGenerator 2> /dev/null
50+
cp -X commandLine/bin/projectGenerator projectGenerator-$PLATFORM/projectGenerator.app/Contents/Resources/app/app/projectGenerator 2> /dev/null
5151
cd ${PG_DIR}
5252
pwd
5353
echo "Directory contents:"

0 commit comments

Comments
 (0)
Please sign in to comment.