一、环境
mac os: 12.4
xcode: 13.4.1
二、步骤
1、创建一个framework工程。
2、添加podfile 一些常用的三方库。
3、设置Build Active Architeture Only 为NO, 让framework支持所有版本。
4、设置Mach-O Type 为Static Library 静态库。
5、设置Excluded Architectures下的 Any ios Simulator SDK 值为 arm64 剔除arm64的架构。
6、设置framework的最低版本
7、修改Scheme 为Release
8、添加一个引用Masonry的测试
9、对外公开此类
记得这里也要添加一下要公开的类
10、添加一个target
创建Aggregate
11、添加一个运行脚本
12、不将podfile三方库打包到framework里
脚本内容
?xml version="1.0" encoding="UTF-8"?
UNIVERSAL_OUTPUTFOLDER=${PROJECT_DIR}/${CONFIGURATION}-universal
WORKSPACE_NAME=${PROJECT_NAME}.xcworkspace
# make sure the output directory exists
mkdir -p"${UNIVERSAL_OUTPUTFOLDER}"
# Step 1. Build Device and Simulator versions
xcodebuild -workspace"${WORKSPACE_NAME}"-scheme"${PROJECT_NAME}"-configuration ${CONFIGURATION} -sdk iphoneos ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}"BUILD_ROOT="${BUILD_ROOT}"clean
xcodebuild -workspace"${WORKSPACE_NAME}"-scheme"${PROJECT_NAME}"-configuration ${CONFIGURATION} -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}"BUILD_ROOT="${BUILD_ROOT}"clean
xcodebuild -workspace"${WORKSPACE_NAME}"-scheme"${PROJECT_NAME}"-configuration ${CONFIGURATION} -sdk iphoneos ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}"BUILD_ROOT="${BUILD_ROOT}"build
xcodebuild -workspace"${WORKSPACE_NAME}"-scheme"${PROJECT_NAME}"-configuration ${CONFIGURATION} -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}"BUILD_ROOT="${BUILD_ROOT}"build
# Step 2. Copy the framework structure (from iphoneos build) to the universal folder
cp -R"${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework""${UNIVERSAL_OUTPUTFOLDER}/"
# Step 4. Create universal binary file using lipo and place the combined executable in the copied framework directory
lipo -create -output"${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/${PROJECT_NAME}""${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework/${PROJECT_NAME}""${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/${PROJECT_NAME}"
# Step 5. Convenience step to copy the framework to the project's directory
cp -R"${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework""${PROJECT_DIR}"
# Step 6. Convenience step to open the project's directory in Finder
open"${PROJECT_DIR}"
13、编译Aggregate 打包framework
获得的包如下
网友评论