From 0ce312998d82c238053975dc6ed03d06e1bb7627 Mon Sep 17 00:00:00 2001 From: ws Date: Tue, 27 Feb 2024 17:02:10 +0800 Subject: [PATCH] Building xcframework --- buildiOSFramework.sh | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/buildiOSFramework.sh b/buildiOSFramework.sh index 8521f75..cda6fde 100755 --- a/buildiOSFramework.sh +++ b/buildiOSFramework.sh @@ -9,19 +9,21 @@ FMK_NAME='AliyunOSSiOS' # Install dir will be the final output to the framework. # The following line create it in the root folder of the current project. -INSTALL_DIR=${SRCROOT}/Products/${FMK_NAME}.framework +INSTALL_DIR=${SRCROOT}/Products/${FMK_NAME}.xcframework # Working dir will be deleted after the framework creation. WRK_DIR=./build -DEVICE_DIR=${WRK_DIR}/Release-iphoneos/${FMK_NAME}.framework -SIMULATOR_DIR=${WRK_DIR}/Release-iphonesimulator/${FMK_NAME}.framework +DEVICE_DIR=${WRK_DIR}/Release-iphoneos/${FMK_NAME} +SIMULATOR_DIR=${WRK_DIR}/Release-iphonesimulator/${FMK_NAME} +DEVICE_FRAMEWORK_DIR=${DEVICE_DIR}.xcarchive/Products/Library/Frameworks/${FMK_NAME}.framework +SIMULATOR_FRAMEWORK_DIR=${SIMULATOR_DIR}.xcarchive/Products/Library/Frameworks/${FMK_NAME}.framework # -configuration ${CONFIGURATION} # Clean and Building both architectures. # xcodebuild -configuration "Release" -target "${FMK_NAME}" -sdk iphoneos clean build # xcodebuild -configuration "Release" -target "${FMK_NAME}" -sdk iphonesimulator clean build -xcodebuild -configuration Release -workspace "${PROJECT_NAME}.xcworkspace" -scheme "${TARGET_NAME}" -sdk iphoneos clean build SYMROOT="${WRK_DIR}" -xcodebuild -configuration Release -workspace "${PROJECT_NAME}.xcworkspace" -scheme "${TARGET_NAME}" -sdk iphonesimulator build SYMROOT="${WRK_DIR}" EXCLUDED_ARCHS="arm64" +xcodebuild archive -workspace "${PROJECT_NAME}.xcworkspace" -scheme "${TARGET_NAME}" -configuration Release -destination 'generic/platform=iOS Simulator' -archivePath "${SIMULATOR_DIR}" SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES +xcodebuild archive -workspace "${PROJECT_NAME}.xcworkspace" -scheme "${TARGET_NAME}" -configuration Release -destination 'generic/platform=iOS' -archivePath "${DEVICE_DIR}" SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES # Cleaning the oldest. if [ -d "${INSTALL_DIR}" ] @@ -31,20 +33,7 @@ fi mkdir -p ${SRCROOT}/Products -cp -LR "${DEVICE_DIR}" "${INSTALL_DIR}" - # Uses the Lipo Tool to merge both binary files (i386/x86_64 + armv7/armv64) into one Universal final product. -lipo -create "${DEVICE_DIR}/${FMK_NAME}" "${SIMULATOR_DIR}/${FMK_NAME}" -output "${INSTALL_DIR}/${FMK_NAME}" +xcodebuild -create-xcframework -framework "${DEVICE_FRAMEWORK_DIR}" -framework "${SIMULATOR_FRAMEWORK_DIR}" -output "${INSTALL_DIR}" rm -r "${WRK_DIR}" - -if [ -d "${INSTALL_DIR}/_CodeSignature" ] -then - rm -rf "${INSTALL_DIR}/_CodeSignature" -fi - -if [ -f "${INSTALL_DIR}/Info.plist" ] -then - rm "${INSTALL_DIR}/Info.plist" -fi -