找到两篇好文章,但发现都有不足之处,所以把两个文章给合并了起来,自己又做了补充
制作framework
FMK_NAME=${PROJECT_NAME}
INSTALL_DIR=${SRCROOT}/Products/${FMK_NAME}.framework
WRK_DIR=build
DEVICE_DIR=${WRK_DIR}/Release-iphoneos/${FMK_NAME}.framework
SIMULATOR_DIR=${WRK_DIR}/Release-iphonesimulator/${FMK_NAME}.framework
xcodebuild -configuration "Release" -target "${FMK_NAME}" -sdk iphoneos -arch armv7 -arch armv7s -arch arm64 clean build
xcodebuild -configuration "Release" -target "${FMK_NAME}" -sdk iphonesimulator -arch x86_64 clean build
if [ -d "${INSTALL_DIR}" ]
then
rm -rf "${INSTALL_DIR}"
fi
mkdir -p "${INSTALL_DIR}"
cp -R "${DEVICE_DIR}/""${INSTALL_DIR}/"
lipo -create "${DEVICE_DIR}/${FMK_NAME}""${SIMULATOR_DIR}/${FMK_NAME}" -output"${INSTALL_DIR}/${FMK_NAME}"
rm -r "${WRK_DIR}"
open "${SRCROOT}/Products/"
但是,问题来了!!!!!!
我们直接添加上面制作好的framework,会发报如下错误:
dyld: Library not loaded: @rpath/RLLibrary.framework/RLLibrary
Referenced from: /var/mobile/Applications/AE92B234-A818-445E-9D69-96E232BD50EB/RLProjectDemo.app/RLProjectDemo Reason: image not found(lldb)
解决方法:仔细看错误原因,应该是没有找到framework文件包,So,怎么编译时打包进去呢?如下图,点击那个+号:
添加Copy Files节点,在Destination中选Frameworks,再点击下面+号,选择自定义的framework,ok,真机 Build,Run,这个世界美好了。