欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

MacOS开发-为install_name_tool添加脚本

程序员文章站 2024-03-24 13:42:58
...

为编译添加install_name_tool脚本,解决每次手动运行的繁琐

install_name_tool的作用?
https://blog.csdn.net/shengpeng3344/article/details/102592191

MacOS开发-为install_name_tool添加脚本
添加一个新的脚本文件
New Run Script Phase
由于Copy Files设置的为Frameworks路径,所以下面脚本都在Frameworks路径处理,脚本内容为

#Copy Files ... replace to cp -r xxx.dylib

#改变dylib的引用地址,防止library/framewokr not found

mkdir -p "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Frameworks"

#cp -r "$SOURCE_ROOT/../GSFrameworks/osx-lib/lib/osx/libwebrtc.dylib" "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Frameworks/"
#libwebrtc
install_name_tool -id "@executable_path/../Frameworks/libwebrtc.dylib" "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Frameworks/libwebrtc.dylib"
install_name_tool -change "/usr/local/lib/libwebrtc.dylib" "@executable_path/../Frameworks/libwebrtc.dylib" "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/$PRODUCT_NAME"
#libVlcFilePlayer
install_name_tool -change "/usr/local/lib/libVlcFilePlayer.dylib" "@executable_path/../Frameworks/libVlcFilePlayer.dylib" "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/$PRODUCT_NAME"
install_name_tool -change "/usr/local/lib/libVlcFilePlayer.dylib" "@executable_path/../Frameworks/libVlcFilePlayer.dylib" "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Frameworks/libRtRoutineOSX.dylib"

install_name_tool -change "$USER_LIBRARY_DIR/libwebrtc.dylib" "@executable_path/../Frameworks/libwebrtc.dylib" "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/$PRODUCT_NAME"

#cp -r "$SOURCE_ROOT/../GSFrameworks/osx-lib/lib/osx/libSwfView.dylib" "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Frameworks/"

install_name_tool -id "@executable_path/../Frameworks/libSwfView.dylib" "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Frameworks/libSwfView.dylib"

install_name_tool -change "/usr/local/lib/libSwfView.dylib" "@executable_path/../Frameworks/libSwfView.dylib" "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/$PRODUCT_NAME"

#install_name_tool -change "$USER_LIBRARY_DIR/libSwfView.dylib" "@rpath/libSwfView.dylib" "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/$PRODUCT_NAME"
install_name_tool -change "$USER_LIBRARY_DIR/libSwfView.dylib" "@executable_path/../Frameworks/libSwfView.dylib" "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/$PRODUCT_NAME"

#cp -r "$SOURCE_ROOT/../GSFrameworks/osx-lib/lib/osx/libRtRoutineOSX.dylib" "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Frameworks/"

install_name_tool -id "@executable_path/../Frameworks/libRtRoutineOSX.dylib" "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Frameworks/libRtRoutineOSX.dylib"

install_name_tool -change "/usr/local/lib/libwebrtc.dylib" "@executable_path/../Frameworks/libwebrtc.dylib" "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Frameworks/libRtRoutineOSX.dylib"

install_name_tool -change "$USER_LIBRARY_DIR/libwebrtc.dylib" "@executable_path/../Frameworks/libwebrtc.dylib" "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Frameworks/libRtRoutineOSX.dylib"

install_name_tool -change "@executable_path/libRtRoutineOSX.dylib" "@executable_path/../Frameworks/libRtRoutineOSX.dylib" "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/$PRODUCT_NAME"