Created
November 8, 2014 05:13
-
-
Save shotamatsuda/597fa656808accf840a2 to your computer and use it in GitHub Desktop.
A script to bundle OpenCV in your applications
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# (1) Add OpenCV's dynamic libraries you need to the pre-created "Link Binary | |
# With Libraries" build phase. | |
# (2) Make a "Copy Files" build phase, configure the destination to | |
# "Frameworks", then add all of the OpenCV's libraries you linked. | |
# (3) Make a "Run Script" build phase and copy and paste the script below. | |
pushd "$BUILT_PRODUCTS_DIR/$FRAMEWORKS_FOLDER_PATH" | |
ls -F | grep -v "@$" | grep "libopencv" | while read; do | |
FILE=$REPLY | |
# Change the linked libraries to the copied ones | |
otool -L "$FILE" | grep "/libopencv" | grep -o "/.*dylib" | while read; do | |
NAME=$(echo $REPLY | egrep -o "[^/]+$") | |
install_name_tool -change "$REPLY" "@executable_path/../Frameworks/$NAME" "$FILE" | |
done | |
# Make a symbolic link of the install name | |
INSTALL_NAME=$(otool -D "$REPLY" | grep -v ":$" | egrep -o "[^/]+$") | |
ln -sf "$REPLY" "$INSTALL_NAME" | |
# Change the install name appropriately | |
install_name_tool -id "@executable_path/../Frameworks/$INSTALL_NAME" "$FILE" | |
done | |
popd | |
# Change the linked libraries to the copied ones | |
pushd $(dirname "$BUILT_PRODUCTS_DIR/$EXECUTABLE_PATH") | |
otool -L "$PRODUCT_NAME" | grep "/libopencv" | grep -o "/.*dylib" | while read; do | |
NAME=$(echo $REPLY | egrep -o "[^/]+$") | |
install_name_tool -change "$REPLY" "@executable_path/../Frameworks/$NAME" "$PRODUCT_NAME" | |
done | |
popd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment