It can be practiced by yourself.
$(PROJECT_DIR) represents the entire project, that is, the entire project folder
$(SRCROOT) represents the project root directory, that is, the folder with the same name as the project under the entire project folder
$(inherited): Inherit the configuration of the previous level or dependency. For projects integrated through CocoaPods, $(inherited) will contain the configuration in Pods.xcodeproj
${PODS_ROOT}: pod directory
recursive: files will be searched recursively in the corresponding directory
non-recursive: non-recursive
#!/bin/sh #The target name to be built TARGET_NAME=${PROJECT_NAME} if [[ $1 ]] then TARGET_NAME=$1 be UNIVERSAL_OUTPUT_FOLDER="${SRCROOT}/Products"
#Create the output directory and delete the previous framework file mkdir -p "${UNIVERSAL_OUTPUT_FOLDER}" rm -rf "${UNIVERSAL_OUTPUT_FOLDER}/${TARGET_NAME}.framework"
#Compile the framework of the simulator and the real machine separately xcodebuild -target "${TARGET_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build xcodebuild -target "${TARGET_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphonesimulator BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
#Copy the framework to the univer directory cp -R "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${TARGET_NAME}.framework" "${UNIVERSAL_OUTPUT_FOLDER}"
#Merge frameworks and output the final framework to the build directory lipo -create -output "${UNIVERSAL_OUTPUT_FOLDER}/${TARGET_NAME}.framework/${TARGET_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${TARGET_NAME}.framework/${TARGET_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphoneos/${TARGET_NAME}.framework/${TARGET_NAME}"
#Delete irrelevant configuration files generated after compilation dir_path="${UNIVERSAL_OUTPUT_FOLDER}/${TARGET_NAME}.framework/" for file in ls $dir_path do if [[ ${file} =~ ".xcconfig" ]] then rm -f "${dir_path}/${file}" be done #Determine whether the build folder exists, delete it if it exists if [ -d "${SRCROOT}/build" ] then rm -rf "${SRCROOT}/build" be rm -rf "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator" "${BUILD_DIR}/${CONFIGURATION}-iphoneos" #Open the merged folder open "${UNIVERSAL_OUTPUT_FOLDER}" |