Skip to content

Commit edc7bb4

Browse files
authored
Add functionality to Xcode template to bundle dylibs (#7358)
#changelog #xcode #osx
1 parent ba89875 commit edc7bb4

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

scripts/templates/osx/Project.xcconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ ICON_FILE = $(OF_PATH)/libs/openFrameworksCompiled/project/osx/$(ICON_NAME)
3232
//APPSTORE, uncomment next lines to bundle data folder and code sign
3333
//OF_CODESIGN = 1
3434
//OF_BUNDLE_DATA_FOLDER = 1
35+
//OF_BUNDLE_DYLIBS = 1
3536

3637
// BOOST - UNCOMMENT BELOW TO ENABLE BOOST
3738
//HEADER_BOOST = "$(OF_PATH)/libs/boost/include"

scripts/templates/osx/emptyExample.xcodeproj/project.pbxproj

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,20 @@
477477
],
478478
"sourceTree": "<group>"
479479
},
480+
"E935D72329ADADAE00AC8EFD": {
481+
"buildActionMask": "2147483647",
482+
"runOnlyForDeploymentPostprocessing": "0",
483+
"outputPaths": [],
484+
"shellPath": "/bin/zsh",
485+
"alwaysOutOfDate": "1",
486+
"inputFileListPaths": [],
487+
"isa": "PBXShellScriptBuildPhase",
488+
"shellScript": "# make sure shell above is set to /bin/zsh\n#\n# requires `brew install dylibbundler` (v1.0.5 as of 20230121)\n#\n# activate via flag in Project.xcconfig\n#\n# note: dylib subdependencies (dylibs that load dylibs) will be found\n#\t\trecursively and bundled within the .app but might need doctoring \n#\t\tto work in both bundled or freestanding states.\n#\n\nif [ -z \"$OF_BUNDLE_DYLIBS\" ] ; then\n\techo \"Not bundling dylibs\";\nelse\n\techo \"Bundling dylibs\";\n\n\t\tflags=(${(@s: :)OTHER_LDFLAGS})\n\t\tdeclare -A paths\n\t\tsargs=\"\"\n\n\t# use the keys of an associative array to accumulate unique directories enclosing .dylibs based on OTHER_LDFLAGS\n\tfor ITEM in $flags; do\n\t\tif [[ $ITEM == *'.dylib' ]] then\n\t\t\td=$(dirname \"$ITEM\")\n\t\t\tpaths[$d]=$d\n\t\tfi\n\tdone\n\t\t\n\t# construct a list of -s args for dylibbuilder to find the dylibs\n\tfor key val in \"${(@kv)paths}\"; do\n\t\tsargs+=-s\\ $key\\ \n\tdone\n\n\t# do the thing\n\t/opt/homebrew/bin/dylibbundler -cd -b -x \"$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/$PRODUCT_NAME\" -d \"$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/libs\" ${(s[ ])sargs}\n\nfi\n",
489+
"files": [],
490+
"inputPaths": [],
491+
"outputFileListPaths": [],
492+
"name": "Run Script — Bundle dylibs"
493+
},
480494
"E4B69B600A3A1757003C02F2": {
481495
"baseConfigurationReference": "E4EB6923138AFD0F00A09F29",
482496
"isa": "XCBuildConfiguration",
@@ -1754,7 +1768,8 @@
17541768
"E4B6FFFD0C3F9AB9008CF71C",
17551769
"E4C2427710CC5ABF004149E2",
17561770
"8466F1851C04CA0E00918B1C",
1757-
"19D6CF9228F07C000044A7EB"
1771+
"19D6CF9228F07C000044A7EB",
1772+
"E935D72329ADADAE00AC8EFD"
17581773
],
17591774
"dependencies": [],
17601775
"name": "emptyExample",

0 commit comments

Comments
 (0)