Skip to content

Instantly share code, notes, and snippets.

@Nillerr
Last active October 3, 2018 06:16
Show Gist options
  • Save Nillerr/6e4fb6d74e23fcf1883342b1a8e27c05 to your computer and use it in GitHub Desktop.
Save Nillerr/6e4fb6d74e23fcf1883342b1a8e27c05 to your computer and use it in GitHub Desktop.
Automatically copies linked Carthage frameworks, without explicitly specifying them in a Run Script build phase. The script works by inspecting the executable build output using otool to create a list of dependencies, and passes them on to the `carthage copy-frameworks` script.
#!/bin/sh
frameworks=$(otool -L $BUILT_PRODUCTS_DIR/$EXECUTABLE_PATH | pcregrep -o1 "@rpath/(.*?\.framework)")
index=0
for framework in $frameworks; do
if [ -e "$SRCROOT/Carthage/Build/iOS/$framework" ]; then
export "SCRIPT_INPUT_FILE_$index"="$SRCROOT/Carthage/Build/iOS/$framework"
export "SCRIPT_OUTPUT_FILE_$index"="$BUILT_PRODUCTS_DIR/$FRAMEWORKS_FOLDER_PATH/$framework"
let index=index+1
fi
done
export SCRIPT_INPUT_FILE_COUNT=$index
export SCRIPT_OUTPUT_FILE_COUNT=$index
eval "/usr/local/bin/carthage copy-frameworks"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment