iOS production framework

参考链接:https://blog.csdn.net/wujakf/article/details/117549786?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522167109143816782412546009%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=167109143816782412546009&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v31_ecpm-13-117549786-null-null.142^v68^control,201^v4^add_ask,213^v2^t3_esquery_v2&utm_term=iOS%20framework%20%E6%97%A0%E6%B3%95%E8%BF%90%E8%A1%8C%E7%9C%9F%E6%9C%BA&spm=1018.2226.3001.4187

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}"

Guess you like

Origin blog.csdn.net/mofengluo/article/details/128849101