Skip to content

Commit

Permalink
Building xcframework
Browse files Browse the repository at this point in the history
  • Loading branch information
wlll129 authored and huiguangjun committed Mar 5, 2024
1 parent 1432689 commit 0ce3129
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions buildiOSFramework.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}" ]
Expand All @@ -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

0 comments on commit 0ce3129

Please sign in to comment.