create-xcframework.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/bash
  2. set -e
  3. set -o pipefail
  4. XCODE_VERSION=$(xcodebuild -version | head -n 1| awk -F ' ' '{print $2}')
  5. XCODE_VERSION_MAJOR=$(echo $XCODE_VERSION | awk -F '.' '{print $1}')
  6. if [ -z "$SRCROOT" ]
  7. then
  8. SRCROOT=$(pwd)
  9. fi
  10. if [ $XCODE_VERSION_MAJOR -lt 11 ]
  11. then
  12. echo "Xcode 10 does not support xcframework. You can still use the individual framework for each platform."
  13. open -a Finder "${SRCROOT}/build/"
  14. exit 0
  15. fi
  16. mkdir -p "${SRCROOT}/build"
  17. PLATFORMS=("iOS" "iOSSimulator" "macOS" "tvOS" "tvOSSimulator" "watchOS" "watchOSSimulator")
  18. if [ $XCODE_VERSION_MAJOR -ge 11 ]
  19. then
  20. PLATFORMS+=("macCatalyst")
  21. fi
  22. if [ $XCODE_VERSION_MAJOR -ge 15 ]
  23. then
  24. PLATFORMS+=("visionOS")
  25. PLATFORMS+=("visionOSSimulator")
  26. fi
  27. COMMAND_ARGS=""
  28. for CURRENT_PLATFORM in "${PLATFORMS[@]}"
  29. do
  30. COMMAND_ARGS="${COMMAND_ARGS} -framework ${SRCROOT}/build/${CURRENT_PLATFORM}/SDWebImage.framework"
  31. done
  32. # Combine XCFramework
  33. xcodebuild -create-xcframework $COMMAND_ARGS -output "${SRCROOT}/build/SDWebImage.xcframework"
  34. open -a Finder "${SRCROOT}/build/SDWebImage.xcframework"