Xcode 11.3 Universal Framework Issue

2.6k views Asked by At

How to Create Custom Universal Framework in Xcode 11.3 and iOS 13, Any run script?

1

There are 1 answers

0
Maverick King On

Step 1: Add new Target from Cross-platform->Aggregate

Step 2: From build phrases add following as run script:

Type a script or drag a script file from your workspace to insert its path.

FRAMEWORK_NAME=${PROJECT_NAME}

SIMULATOR_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${FRAMEWORK_NAME}.framework"

DEVICE_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphoneos/${FRAMEWORK_NAME}.framework"

DEVICE_BCSYMBOLMAP_PATH="${BUILD_DIR}/${CONFIGURATION}-iphoneos"

DEVICE_DSYM_PATH="${BUILD_DIR}/${CONFIGURATION}-iphoneos/${FRAMEWORK_NAME}.framework.dSYM"

SIMULATOR_DSYM_PATH="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${FRAMEWORK_NAME}.framework.dSYM"

UNIVERSAL_LIBRARY_DIR="${BUILD_DIR}/${CONFIGURATION}-iphoneuniversal"

FRAMEWORK="${UNIVERSAL_LIBRARY_DIR}/${FRAMEWORK_NAME}.framework"

OUTPUT_DIR="./Build-Framework"

DRPBOX_DIR="/Users/$USER/Dropbox/Frameworks/iTelMessagingKit"

This builds your framework for the target simulator.

Xcodebuild -project ${PROJECT_NAME}.Xcodeproj -UseModernBuildSystem=NO -scheme ${FRAMEWORK_NAME} -sdk iphonesimulator -configuration ${CONFIGURATION} clean install CONFIGURATION_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphonesimulator

This builds your framework for the device.

Xcodebuild -project ${PROJECT_NAME}.Xcodeproj -UseModernBuildSystem=NO -scheme ${FRAMEWORK_NAME} -sdk iphoneos -configuration ${CONFIGURATION} clean install CONFIGURATION_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphoneos

Let’s clean up the final directories:

rm -rf "${UNIVERSAL_LIBRARY_DIR}"

mkdir "${UNIVERSAL_LIBRARY_DIR}"

mkdir "${FRAMEWORK}"

rm -rf "$OUTPUT_DIR" mkdir -p "$OUTPUT_DIR"

Now, we take one of the framework files to our universal folder:

cp -r "${DEVICE_LIBRARY_PATH}/." "${FRAMEWORK}"

Now for the real magic, lipo, add this snippet:

lipo "${SIMULATOR_LIBRARY_PATH}/${FRAMEWORK_NAME}" "${DEVICE_LIBRARY_PATH}/${FRAMEWORK_NAME}" -create -output "${FRAMEWORK}/${FRAMEWORK_NAME}" | echo cp -r "${FRAMEWORK}" "$OUTPUT_DIR"

cp -r "${FRAMEWORK}" "$DRPBOX_DIR"