在执行以下步骤之前,我们使用脚本来创建 FAT 框架。
- 为 iOS 设备创建框架
- 为模拟器设备创建框架
- 合并上述两个框架,它将成为您的 FAT / 通用框架。
XCODE 12.4 之后相同的脚本无法正常工作,因此似乎有一些特定于 XCODE 13+ 的更改。
任何人都可以指导使用XCODE 13创建 FAT/通用框架的步骤吗?
在执行以下步骤之前,我们使用脚本来创建 FAT 框架。
XCODE 12.4 之后相同的脚本无法正常工作,因此似乎有一些特定于 XCODE 13+ 的更改。
任何人都可以指导使用XCODE 13创建 FAT/通用框架的步骤吗?
试试这个“构建阶段”->单击“+”图标->“新运行脚本阶段”复制下面的代码并使用模拟器和任何 iOS 设备构建。你的胖框架将在你的项目文件夹中
#1. After then make a fresh directory directory
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
# make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
# 2. Copy Device(arm64) Framework at fresh universal folder location
cp -a "${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework" "${UNIVERSAL_OUTPUTFOLDER}/"
#3. Copy Sim(x86_64) Frameworks's "MyFramework.swiftmodule" Folder Content & paste it at Fat(x86_64 + arm64) Frameworks's "MyFramework.swiftmodule" folder.
SIMULATOR_SWIFT_MODULES_DIR="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework/Modules/${PROJECT_NAME}.swiftmodule/."
if [ -d "${SIMULATOR_SWIFT_MODULES_DIR}" ]; then
cp -R "${SIMULATOR_SWIFT_MODULES_DIR}" "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/Modules/${PROJECT_NAME}.swiftmodule"
fi
# 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}" "${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework/${PROJECT_NAME}"
# Step 5. Copy output at Project Directory
cp -R "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework" "${PROJECT_DIR}"
# Step 6. Open Project Directory
open "${PROJECT_DIR}"#1. After then make a fresh directory directory
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
# make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
# 2. Copy Device(arm64) Framework at fresh universal folder location
cp -a "${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework" "${UNIVERSAL_OUTPUTFOLDER}/"
#3. Copy Sim(x86_64) Frameworks's "MyFramework.swiftmodule" Folder Content & paste it at Fat(x86_64 + arm64) Frameworks's "MyFramework.swiftmodule" folder.
SIMULATOR_SWIFT_MODULES_DIR="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework/Modules/${PROJECT_NAME}.swiftmodule/."
if [ -d "${SIMULATOR_SWIFT_MODULES_DIR}" ]; then
cp -R "${SIMULATOR_SWIFT_MODULES_DIR}" "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/Modules/${PROJECT_NAME}.swiftmodule"
fi
# 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}" "${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework/${PROJECT_NAME}"
# Step 5. Copy output at Project Directory
cp -R "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework" "${PROJECT_DIR}"
# Step 6. Open Project Directory
open "${PROJECT_DIR}"