#!/bin/bash set -e WORKING_DIR=$(pwd) FRAMEWORK_FOLDER_NAME="XCFramework" FRAMEWORK_NAME="#{plugin_name}" FRAMEWORK_PATH="${WORKING_DIR}/${FRAMEWORK_FOLDER_NAME}/${FRAMEWORK_NAME}.xcframework" BUILD_SCHEME="#{plugin_name}Framework" SIMULATOR_ARCHIVE_PATH="${WORKING_DIR}/${FRAMEWORK_FOLDER_NAME}/simulator.xcarchive" IOS_DEVICE_ARCHIVE_PATH="${WORKING_DIR}/${FRAMEWORK_FOLDER_NAME}/iOS.xcarchive" rm -rf "${WORKING_DIR}/${FRAMEWORK_FOLDER_NAME}" echo "Deleted ${FRAMEWORK_FOLDER_NAME}" mkdir "${FRAMEWORK_FOLDER_NAME}" echo "Created ${FRAMEWORK_FOLDER_NAME}" echo "Archiving ${FRAMEWORK_NAME}" xcodebuild -workspace "#{plugin_name}.xcworkspace" archive ONLY_ACTIVE_ARCH=NO ARCHS="x86_64 arm64 i386" -scheme ${BUILD_SCHEME} -destination="generic/platform=iOS Simulator" -archivePath "${SIMULATOR_ARCHIVE_PATH}" -sdk iphonesimulator SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES xcodebuild archive -workspace "#{plugin_name}.xcworkspace" -scheme ${BUILD_SCHEME} -destination="generic/platform=iOS" -archivePath "${IOS_DEVICE_ARCHIVE_PATH}" -sdk iphoneos SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES xcodebuild -create-xcframework -framework ${SIMULATOR_ARCHIVE_PATH}/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework -framework ${IOS_DEVICE_ARCHIVE_PATH}/Products/Library/Frameworks/${FRAMEWORK_NAME}.framework -output "${FRAMEWORK_PATH}" rm -rf "${SIMULATOR_ARCHIVE_PATH}" rm -rf "${IOS_DEVICE_ARCHIVE_PATH}"