一章钾、環(huán)境
mac os: 12.4
xcode: 13.4.1
二、步驟
1、創(chuàng)建一個framework工程帆卓。
2碍脏、添加podfile 一些常用的三方庫河闰。
3儡炼、設置Build Active Architeture Only 為NO,? 讓framework支持所有版本沮趣。
4凌蔬、設置Mach-O Type 為Static Library 靜態(tài)庫。
5褐桌、設置Excluded Architectures下的?Any ios Simulator SDK 值為 arm64 剔除arm64的架構汪厨。
6殖妇、設置framework的最低版本
7、修改Scheme 為Release
8、添加一個引用Masonry的測試
9探膊、對外公開此類
記得這里也要添加一下要公開的類
10分瘦、添加一個target
創(chuàng)建Aggregate
11旺坠、添加一個運行腳本
12崩侠、不將podfile三方庫打包到framework里
腳本內(nèi)容
?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
獲得的包如下