制作带armv7 x86_64 arm64 架构的framework

制作带真机、模拟器架构(即armv7、x86_64、arm64)的framework时,只需在Xcode工程的 Build Phases中添加以下脚本:

if  [ "${ACTION}" = "build" ]
then
INSTALL_DIR=${SRCROOT}/Products/${PROJECT_NAME}.framework
DEVICE_DIR=${BUILD_ROOT}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework
SIMULATOR_DIR=${BUILD_ROOT}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework
fi

if  [ -d "${INSTALL_DIR}" ]
then
m -rf "${INSTALL_DIR}"
fi

mkdir -p "${INSTALL_DIR}"
cp -R "${DEVICE_DIR}/" "${INSTALL_DIR}/"

lipo -create "${DEVICE_DIR}/${PROJECT_NAME}" "${SIMULATOR_DIR}/${PROJECT_NAME}" -output "${INSTALL_DIR}/${PROJECT_NAME}"
#最终生成带真机、模拟器架构的framework在项目目录的Products文件中
open "${SRCROOT}/Products"

Build项目, 使用 lipo -info xxx命令检查生成的framework,以包含armv7、x86_64、arm64

你可能感兴趣的:(制作带armv7 x86_64 arm64 架构的framework)