I'm trying to do something pretty simple and typical, which is use dynamically linked libraries in my Xcode project and then deploy with all the necessary libraries embedded.
However I must be doing something the wrong way, because Xcode 8 won't allow me to embed .dylib files, only frameworks! The picture below is what happens when I try to add anything to Embedded Binaires, the dylibs just don't show up, and Add Other... adds them to the project but not to Embedded Binaries.
There must be a very simple way to do it but I just can't find it...
Epilogue
So apparently since I do need to run a script that calls install_lib_tool
I made a pretty universal script that will change anything that has /local/
in its path to the path of the embedded copy:
#!/bin/sh
app=$BUILT_PRODUCTS_DIR/$EXECUTABLE_PATH
fw_path=$BUILT_PRODUCTS_DIR/$FRAMEWORKS_FOLDER_PATH
app_dyl_list=(`ls $fw_path | grep dylib`)
function change_paths {
local bin=$1
echo change_path $bin
dyl_list=(`otool -L $bin | grep local | awk '{print $1}'`)
for dyl in ${dyl_list[*]}; do
libname=$(basename $dyl)
libname=${libname%%.*}
actual_libname=(`ls $fw_path | grep $libname | xargs basename`)
install_name_tool -change $dyl "@executable_path/../Frameworks/$actual_libname" $bin
printf "\t%s edited\n" $actual_libname
done
}
change_paths $app
for dyl_bin in ${app_dyl_list[*]}; do
change_paths $fw_path/$dyl_bin
done
Then all it takes is adding a Run Script step after the copying of the dylibs to just run it with no arguments (the environment variables contain everything needed).