Hi,
I have been trying to modify the existing build script of my project (which used to build a .framework) to build .XCFramework but I am getting the below error
binaries with multiple platforms are not supported '/Users/CodeForever/Library/Developer/Xcode/DerivedData/MySDK-cjavkiibuxlwhgftpsbjmlkavwpx/Build/Products/Debug-iphonesimulator/libMySDK.a'
Not sure what am I missing here. Can someone please help me understand what could I be missing in the script or settings?
Please refer the complete script below: (running this on Xcode v15.0)
#!/bin/bash
If we're already inside this script then die
if [ -n "$RW_MULTIPLATFORM_BUILD_IN_PROGRESS" ]; then exit 0 fi export RW_MULTIPLATFORM_BUILD_IN_PROGRESS=1
RW_FRAMEWORK_NAME=${PROJECT_NAME} RW_XCFRAMEWORK_LOCATION="${BUILT_PRODUCTS_DIR}/${RW_FRAMEWORK_NAME}.xcframework"
Function to build a static library for a specific platform
function build_static_library {
# build_static_library sdk
xcrun xcodebuild -project "${PROJECT_FILE_PATH}"
-target "${TARGET_NAME}"
-configuration "${CONFIGURATION}"
-sdk "${1}"
ONLY_ACTIVE_ARCH=NO
BUILD_DIR="${BUILD_DIR}"
OBJROOT="${OBJROOT}/DependentBuilds"
BUILD_ROOT="${BUILD_ROOT}"
SYMROOT="${SYMROOT}" $ACTION
}
Build for the iOS device
build_static_library "iphoneos"
Create the iOS device XCFramework
xcodebuild -create-xcframework
-library "${BUILT_PRODUCTS_DIR}/lib${PROJECT_NAME}.a"
-output "${RW_XCFRAMEWORK_LOCATION}_iphoneos.xcframework"
Build for the iOS Simulator
build_static_library "iphonesimulator"
Create the iOS Simulator XCFramework
xcodebuild -create-xcframework
-library "${BUILT_PRODUCTS_DIR}/lib${PROJECT_NAME}.a"
-output "${RW_XCFRAMEWORK_LOCATION}_iphonesimulator.xcframework"
Merge the two XCFrameworks into a universal XCFramework
xcodebuild -create-xcframework
-framework "${RW_XCFRAMEWORK_LOCATION}_iphoneos.xcframework"
-framework "${RW_XCFRAMEWORK_LOCATION}_iphonesimulator.xcframework"
-output "$RW_XCFRAMEWORK_LOCATION"
Remove temporary XCFrameworks
rm -r "${RW_XCFRAMEWORK_LOCATION}_iphoneos.xcframework" rm -r "${RW_XCFRAMEWORK_LOCATION}_iphonesimulator.xcframework"
Copy the XCFramework to the user's desktop
cp -r "$RW_XCFRAMEWORK_LOCATION" "${HOME}/Desktop/${RW_FRAMEWORK_NAME}.xcframework"