diff --git a/SDWebImage.xcodeproj/project.pbxproj b/SDWebImage.xcodeproj/project.pbxproj index 78ec954c..5a4af183 100644 --- a/SDWebImage.xcodeproj/project.pbxproj +++ b/SDWebImage.xcodeproj/project.pbxproj @@ -1140,10 +1140,12 @@ "$(SRCROOT)/build/watchos/SDWebImage.framework", "$(SRCROOT)/build/watchsimulator/SDWebImage.framework", "$(SRCROOT)/build/maccatalyst/SDWebImage.framework", + "$(SRCROOT)/build/xros/SDWebImage.framework", + "$(SRCROOT)/build/xrsimulator/SDWebImage.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "XCODE_VERSION=$(xcodebuild -version | head -n 1| awk -F ' ' '{print $2}')\nXCODE_VERSION_MAJOR=$(echo $XCODE_VERSION | awk -F '.' '{print $1}')\n\nmkdir -p $(SRCROOT)/build\ndeclare -a PLATFORMS=(\"iphoneos\" \"iphonesimulator\" \"macosx\" \"appletvos\" \"appletvsimulator\" \"watchos\" \"watchsimulator\" \"maccatalyst\")\nfor CURRENT_PLATFORM in \"${PLATFORMS[@]}\"\ndo\n if [[ $CURRENT_PLATFORM == *\"simulator\" ]]; then\n xcodebuild build -project \"SDWebImage.xcodeproj\" -sdk \"${CURRENT_PLATFORM}\" -scheme \"SDWebImage\" -configuration \"Debug\" -derivedDataPath \"${SRCROOT}/build/DerivedData\" CONFIGURATION_BUILD_DIR=\"${SRCROOT}/build/${CURRENT_PLATFORM}/\"\n else\n # macOS Catalyst\n if [[ $CURRENT_PLATFORM == \"maccatalyst\" ]]; then\n if [[ $XCODE_VERSION_MAJOR -lt 11 ]]; then\n # Xcode 10 does not support macOS Catalyst\n continue\n else\n xcodebuild archive -project \"SDWebImage.xcodeproj\" -scheme \"SDWebImage\" -configuration \"Release\" -destination 'platform=macOS,arch=x86_64,variant=Mac Catalyst' -archivePath \"${SRCROOT}/build/${CURRENT_PLATFORM}/SDWebImage.xcarchive\" -derivedDataPath \"${SRCROOT}/build/DerivedData\" SKIP_INSTALL=NO\n fi\n else\n xcodebuild archive -project \"SDWebImage.xcodeproj\" -sdk \"${CURRENT_PLATFORM}\" -scheme \"SDWebImage\" -configuration \"Release\" -archivePath \"${SRCROOT}/build/${CURRENT_PLATFORM}/SDWebImage.xcarchive\" SKIP_INSTALL=NO\n fi\n mv \"${SRCROOT}/build/${CURRENT_PLATFORM}/SDWebImage.xcarchive/Products/Library/Frameworks/SDWebImage.framework\" \"${SRCROOT}/build/${CURRENT_PLATFORM}/\"\n mv \"${SRCROOT}/build/${CURRENT_PLATFORM}/SDWebImage.xcarchive/dSYMs/SDWebImage.framework.dSYM\" \"${SRCROOT}/build/${CURRENT_PLATFORM}/\"\n rm -rf \"${SRCROOT}/build/${CURRENT_PLATFORM}/SDWebImage.xcarchive/\"\n fi\ndone\n"; + shellScript = "sh ${SRCROOT}/Scripts/build-frameworks.sh\n"; }; 326CA51422BA25F70033A92F /* Create XCFramework */ = { isa = PBXShellScriptBuildPhase; @@ -1161,6 +1163,8 @@ "$(SRCROOT)/build/watchos/SDWebImage.framework", "$(SRCROOT)/build/watchsimulator/SDWebImage.framework", "$(SRCROOT)/build/maccatalyst/SDWebImage.framework", + "$(SRCROOT)/build/xros/SDWebImage.framework", + "$(SRCROOT)/build/xrsimulator/SDWebImage.framework", ); name = "Create XCFramework"; outputFileListPaths = ( @@ -1170,7 +1174,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "XCODE_VERSION=$(xcodebuild -version | head -n 1| awk -F ' ' '{print $2}')\nXCODE_VERSION_MAJOR=$(echo $XCODE_VERSION | awk -F '.' '{print $1}')\n\nif [ $XCODE_VERSION_MAJOR -lt 11 ]\nthen\n echo \"Xcode 10 does not support xcframework. You can still use the individual framework for each platform.\"\n open -a Finder \"${SRCROOT}/build/\"\n exit 0\nfi\n\ndeclare -a PLATFORMS=(\"iphoneos\" \"iphonesimulator\" \"macosx\" \"appletvos\" \"appletvsimulator\" \"watchos\" \"watchsimulator\" \"maccatalyst\")\nCOMMAND_ARGS=\"\"\nfor CURRENT_PLATFORM in \"${PLATFORMS[@]}\"\ndo\n COMMAND_ARGS=\"${COMMAND_ARGS} -framework ${SRCROOT}/build/${CURRENT_PLATFORM}/SDWebImage.framework\"\ndone\n\n# Combine XCFramework\nxcodebuild -create-xcframework $COMMAND_ARGS -output \"${SRCROOT}/build/SDWebImage.xcframework\"\nopen -a Finder \"${SRCROOT}/build/SDWebImage.xcframework\"\n"; + shellScript = "sh ${SRCROOT}/Scripts/create-xcframework.sh\n"; }; /* End PBXShellScriptBuildPhase section */ diff --git a/Scripts/build-frameworks.sh b/Scripts/build-frameworks.sh new file mode 100755 index 00000000..60744f49 --- /dev/null +++ b/Scripts/build-frameworks.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +XCODE_VERSION=$(xcodebuild -version | head -n 1| awk -F ' ' '{print $2}') +XCODE_VERSION_MAJOR=$(echo $XCODE_VERSION | awk -F '.' '{print $1}') +if [ -z "$SRCROOT" ] +then + SRCROOT=$(pwd) +fi + +mkdir -p "${SRCROOT}/build" +declare -a PLATFORMS=("iphoneos" "iphonesimulator" "macosx" "appletvos" "appletvsimulator" "watchos" "watchsimulator" "maccatalyst") + +if [ $XCODE_VERSION_MAJOR -ge 15 ] +then + PLATFORMS+=("xros") + PLATFORMS+=("xrsimulator") +fi + +for CURRENT_PLATFORM in "${PLATFORMS[@]}" +do + if [[ $CURRENT_PLATFORM == *"simulator" ]]; then + xcodebuild build -project "SDWebImage.xcodeproj" -sdk "${CURRENT_PLATFORM}" -scheme "SDWebImage" -configuration "Debug" -derivedDataPath "${SRCROOT}/build/DerivedData" CONFIGURATION_BUILD_DIR="${SRCROOT}/build/${CURRENT_PLATFORM}/" + else + # macOS Catalyst + if [[ $CURRENT_PLATFORM == "maccatalyst" ]]; then + if [[ $XCODE_VERSION_MAJOR -lt 11 ]]; then + # Xcode 10 does not support macOS Catalyst + continue + else + xcodebuild archive -project "SDWebImage.xcodeproj" -scheme "SDWebImage" -configuration "Release" -destination 'platform=macOS,arch=x86_64,variant=Mac Catalyst' -archivePath "${SRCROOT}/build/${CURRENT_PLATFORM}/SDWebImage.xcarchive" -derivedDataPath "${SRCROOT}/build/DerivedData" SKIP_INSTALL=NO + fi + else + xcodebuild archive -project "SDWebImage.xcodeproj" -sdk "${CURRENT_PLATFORM}" -scheme "SDWebImage" -configuration "Release" -archivePath "${SRCROOT}/build/${CURRENT_PLATFORM}/SDWebImage.xcarchive" SKIP_INSTALL=NO + fi + mv "${SRCROOT}/build/${CURRENT_PLATFORM}/SDWebImage.xcarchive/Products/Library/Frameworks/SDWebImage.framework" "${SRCROOT}/build/${CURRENT_PLATFORM}/" + mv "${SRCROOT}/build/${CURRENT_PLATFORM}/SDWebImage.xcarchive/dSYMs/SDWebImage.framework.dSYM" "${SRCROOT}/build/${CURRENT_PLATFORM}/" + rm -rf "${SRCROOT}/build/${CURRENT_PLATFORM}/SDWebImage.xcarchive/" + fi +done diff --git a/Scripts/create-xcframework.sh b/Scripts/create-xcframework.sh new file mode 100755 index 00000000..c6905ea0 --- /dev/null +++ b/Scripts/create-xcframework.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +XCODE_VERSION=$(xcodebuild -version | head -n 1| awk -F ' ' '{print $2}') +XCODE_VERSION_MAJOR=$(echo $XCODE_VERSION | awk -F '.' '{print $1}') +if [ -z "$SRCROOT" ] +then + SRCROOT=$(pwd) +fi + +if [ $XCODE_VERSION_MAJOR -lt 11 ] +then + echo "Xcode 10 does not support xcframework. You can still use the individual framework for each platform." + open -a Finder "${SRCROOT}/build/" + exit 0 +fi + +declare -a PLATFORMS=("iphoneos" "iphonesimulator" "macosx" "appletvos" "appletvsimulator" "watchos" "watchsimulator") + +if [ $XCODE_VERSION_MAJOR -ge 15 ] +then + PLATFORMS+=("xros") + PLATFORMS+=("xrsimulator") +fi + +COMMAND_ARGS="" +for CURRENT_PLATFORM in "${PLATFORMS[@]}" +do + COMMAND_ARGS="${COMMAND_ARGS} -framework ${SRCROOT}/build/${CURRENT_PLATFORM}/SDWebImage.framework" +done + +# Combine XCFramework +xcodebuild -create-xcframework $COMMAND_ARGS -output "${SRCROOT}/build/SDWebImage.xcframework" +open -a Finder "${SRCROOT}/build/SDWebImage.xcframework"