diff --git a/.github/workflows/deploy-release-artifacts.yml b/.github/workflows/deploy-release-artifacts.yml index 0d22779..6dd211c 100644 --- a/.github/workflows/deploy-release-artifacts.yml +++ b/.github/workflows/deploy-release-artifacts.yml @@ -14,12 +14,14 @@ jobs: uses: actions/checkout@v2 - name: Create XCFramework - uses: philprime/swift-create-xcframework@v2 + run: ./Scripts/build-xcframework.sh + env: + PROJECT_FILE: Differ.xcodeproj + SCHEME_NAME: Differ + OUTPUT_DIR: ${{ runner.temp }} - name: Release XCFramework uses: softprops/action-gh-release@v1 with: fail_on_unmatched_files: true - files: | - Differ-*.zip - Differ-*.sha256 + files: ${{ runner.temp }}/Differ.xcframework.zip diff --git a/Scripts/build-xcframework.sh b/Scripts/build-xcframework.sh new file mode 100755 index 0000000..78ee081 --- /dev/null +++ b/Scripts/build-xcframework.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash + +set -o errexit +set -o nounset + +OUTPUT_DIR=${OUTPUT_DIR?error: Please provide the build directory via the 'OUTPUT_DIR' environment variable} +PROJECT_FILE=${PROJECT_FILE?error: Please provide the Xcode project file name via the 'PROJECT_FILE' environment variable} +SCHEME_NAME=${SCHEME_NAME?error: Please provide the Xcode scheme to build via the 'SCHEME_NAME' environment variable} + +# Generate iOS framework +xcodebuild -project "${PROJECT_FILE}" -configuration Release -archivePath "${OUTPUT_DIR}/${SCHEME_NAME}-iphoneos.xcarchive" -destination "generic/platform=iOS" SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES -scheme "${SCHEME_NAME}" archive + +# Generate iOS Simulator framework +xcodebuild -project "${PROJECT_FILE}" -configuration Release -archivePath "${OUTPUT_DIR}/${SCHEME_NAME}-iossimulator.xcarchive" -destination "generic/platform=iOS Simulator" SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES -scheme "${SCHEME_NAME}" archive + +# Generate macOS framework +xcodebuild -project "${PROJECT_FILE}" -configuration Release -archivePath "${OUTPUT_DIR}/${SCHEME_NAME}-macosx.xcarchive" -destination "generic/platform=macOS,name=Any Mac" SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES -scheme "${SCHEME_NAME}" archive + +# Generate macOS Catalyst framework +xcodebuild -project "${PROJECT_FILE}" -configuration Release -archivePath "${OUTPUT_DIR}/${SCHEME_NAME}-maccatalyst.xcarchive" -destination "generic/platform=macOS,variant=Mac Catalyst" SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES SUPPORTS_MACCATALYST=YES -scheme "${SCHEME_NAME}" archive + +# Generate tvOS framework +xcodebuild -project "${PROJECT_FILE}" -configuration Release -archivePath "${OUTPUT_DIR}/${SCHEME_NAME}-appletvos.xcarchive" -destination "generic/platform=tvOS" SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES -scheme "${SCHEME_NAME}" archive + +# Generate tvOS Simulator framework +xcodebuild -project "${PROJECT_FILE}" -configuration Release -archivePath "${OUTPUT_DIR}/${SCHEME_NAME}-appletvsimulator.xcarchive" -destination "generic/platform=tvOS Simulator" SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES -scheme "${SCHEME_NAME}" archive + +# Generate watchOS framework +xcodebuild -project "${PROJECT_FILE}" -configuration Release -archivePath "${OUTPUT_DIR}/${SCHEME_NAME}-watchos.xcarchive" -destination "generic/platform=watchOS" SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES -scheme "${SCHEME_NAME}" archive + +# Generate watchOS Simulator framework +xcodebuild -project "${PROJECT_FILE}" -configuration Release -archivePath "${OUTPUT_DIR}/${SCHEME_NAME}-watchsimulator.xcarchive" -destination "generic/platform=watchOS Simulator" SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES -scheme "${SCHEME_NAME}" archive + +# Generate XCFramework +xcodebuild -create-xcframework \ + -archive "${OUTPUT_DIR}/${SCHEME_NAME}-appletvos.xcarchive" -framework "${SCHEME_NAME}.framework" \ + -archive "${OUTPUT_DIR}/${SCHEME_NAME}-appletvsimulator.xcarchive" -framework "${SCHEME_NAME}.framework" \ + -archive "${OUTPUT_DIR}/${SCHEME_NAME}-iphoneos.xcarchive" -framework "${SCHEME_NAME}.framework" \ + -archive "${OUTPUT_DIR}/${SCHEME_NAME}-iossimulator.xcarchive" -framework "${SCHEME_NAME}.framework" \ + -archive "${OUTPUT_DIR}/${SCHEME_NAME}-macosx.xcarchive" -framework "${SCHEME_NAME}.framework" \ + -archive "${OUTPUT_DIR}/${SCHEME_NAME}-maccatalyst.xcarchive" -framework "${SCHEME_NAME}.framework" \ + -archive "${OUTPUT_DIR}/${SCHEME_NAME}-watchos.xcarchive" -framework "${SCHEME_NAME}.framework" \ + -archive "${OUTPUT_DIR}/${SCHEME_NAME}-watchsimulator.xcarchive" -framework "${SCHEME_NAME}.framework" \ + -output "${OUTPUT_DIR}/${SCHEME_NAME}.xcframework" + +# Zip it! +ditto -c -k --rsrc --keepParent "${OUTPUT_DIR}/${SCHEME_NAME}.xcframework" "${OUTPUT_DIR}/${SCHEME_NAME}.xcframework.zip" +rm -rf "${OUTPUT_DIR}/${SCHEME_NAME}.xcframework" diff --git a/Supporting Files/Configurations/Universal-Framework-Target.xcconfig b/Supporting Files/Configurations/Universal-Framework-Target.xcconfig index 5898b60..9d3fd7e 100644 --- a/Supporting Files/Configurations/Universal-Framework-Target.xcconfig +++ b/Supporting Files/Configurations/Universal-Framework-Target.xcconfig @@ -1,6 +1,6 @@ #include "Universal-Target-Base.xcconfig" -// OSX-specific default settings +// macOS-specific default settings FRAMEWORK_VERSION[sdk=macosx*] = A COMBINE_HIDPI_IMAGES[sdk=macosx*] = YES diff --git a/Supporting Files/Configurations/Universal-Target-Base.xcconfig b/Supporting Files/Configurations/Universal-Target-Base.xcconfig index 9900e9a..9f0888d 100644 --- a/Supporting Files/Configurations/Universal-Target-Base.xcconfig +++ b/Supporting Files/Configurations/Universal-Target-Base.xcconfig @@ -1,11 +1,6 @@ -SUPPORTED_PLATFORMS = macosx iphonesimulator iphoneos watchos watchsimulator appletvos appletvsimulator -VALID_ARCHS[sdk=macosx*] = i386 x86_64 arm64 -VALID_ARCHS[sdk=iphone*] = arm64 armv7 armv7s -VALID_ARCHS[sdk=iphonesimulator*] = i386 x86_64 -VALID_ARCHS[sdk=watch*] = armv7k -VALID_ARCHS[sdk=watchsimulator*] = i386 x86_64 -VALID_ARCHS[sdk=appletv*] = arm64 -VALID_ARCHS[sdk=appletvsimulator*] = i386 x86_64 +ALLOW_TARGET_PLATFORM_SPECIALIZATION = YES +SUPPORTED_PLATFORMS = macosx iphonesimulator iphoneos watchos watchsimulator appletvos appletvsimulator +SUPPORTS_MACCATALYST = YES // Dynamic linking uses different default copy paths LD_RUNPATH_SEARCH_PATHS[sdk=macosx*] = $(inherited) '@executable_path/../Frameworks' '@loader_path/../Frameworks'