+ "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",
0 commit comments