From 6a55563307d6190987b91b394b230ca5e23019e2 Mon Sep 17 00:00:00 2001 From: Jonas Zaugg Date: Wed, 29 Jul 2020 14:06:08 +0200 Subject: [PATCH] Add SPM binary target support --- .gitignore | 4 ++++ Configurations/make-release-package.sh | 17 ++++++++++++++ Makefile | 5 +++- Package-template.swift | 23 +++++++++++++++++++ Package.swift | 23 +++++++++++++++++++ .../xcschemes/Distribution.xcscheme | 2 +- 6 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 Package-template.swift create mode 100644 Package.swift diff --git a/.gitignore b/.gitignore index b18d235c..7ef5cd20 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,7 @@ Carthage/Build Network Trash Folder Temporary Items .apdisk + +# Swift Package Manager +/.build +.swiftpm diff --git a/Configurations/make-release-package.sh b/Configurations/make-release-package.sh index 3014c1e4..ac3a58ce 100755 --- a/Configurations/make-release-package.sh +++ b/Configurations/make-release-package.sh @@ -57,4 +57,21 @@ if [ "$ACTION" = "" ] ; then # Sorted file list groups similar files together, which improves tar compression find . \! -type d | rev | sort | rev | tar cv --files-from=- | xz -9 > "../Sparkle-$CURRENT_PROJECT_VERSION.tar.xz" rm -rf "$CONFIGURATION_BUILD_DIR/staging" + + # Generate zip containing the xcframework for SPM + cd "$CONFIGURATION_BUILD_DIR" + rm -rf "Sparkle.xcarchive" + zip -rqyX "Sparkle-SPM-$CURRENT_PROJECT_VERSION.zip" "Sparkle.xcframework" + # Generate new Package manifest + cp "$SRCROOT/Package-template.swift" "$CONFIGURATION_BUILD_DIR" + mv "Package-template.swift" "Package.swift" + # is equivalent to shasum -a 256 FILE + spm_checksum=$(swift package compute-checksum "Sparkle-SPM-$CURRENT_PROJECT_VERSION.zip") + rm -rf ".build" + sed -i '' -e "s/VERSION_PLACEHOLDER/$CURRENT_PROJECT_VERSION/g" "Package.swift" + sed -i '' -e "s/CHECKSUM_PLACEHOLDER/$spm_checksum/g" "Package.swift" + cp "Package.swift" "$SRCROOT" + echo "Package.swift updated with the following values:" + echo "Version: $CURRENT_PROJECT_VERSION" + echo "Checksum: $spm_checksum" fi diff --git a/Makefile b/Makefile index 2eaced72..072d1d45 100644 --- a/Makefile +++ b/Makefile @@ -13,10 +13,13 @@ localizable-strings: rm Sparkle/en.lproj/Localizable.strings release: + xcodebuild -scheme Sparkle -configuration Release -derivedDataPath "$(BUILDDIR)" -archivePath "$(BUILDDIR)/Build/Products/Release/Sparkle.xcarchive" BUILD_LIBRARY_FOR_DISTRIBUTION=YES SKIP_INSTALL=NO archive + xcodebuild -create-xcframework -framework "$(BUILDDIR)/Build/Products/Release/Sparkle.xcarchive/Products/Library/Frameworks/Sparkle.framework" -output "$(BUILDDIR)/Build/Products/Release/Sparkle.xcframework" xcodebuild -scheme Distribution -configuration Release -derivedDataPath "$(BUILDDIR)" build - open -R "$(BUILDDIR)/Build/Products/Release/Sparkle-"*.tar.bz2 + open "$(BUILDDIR)/Build/Products/Release/" cat Sparkle.podspec @echo "Don't forget to update CocoaPods! pod trunk push" + @echo "Don't forget to commit the updated Package manifest before releasing!" build: xcodebuild clean build diff --git a/Package-template.swift b/Package-template.swift new file mode 100644 index 00000000..8915811a --- /dev/null +++ b/Package-template.swift @@ -0,0 +1,23 @@ +// swift-tools-version:5.3 +import PackageDescription + +let version = "VERSION_PLACEHOLDER" +let checksum = "CHECKSUM_PLACEHOLDER" +let url = "https://github.com/sparkle-project/Sparkle/releases/download/\(version)/Sparkle-SPM-\(version).zip" + +let package = Package( + name: "Sparkle", + platforms: [.macOS(.v10_11)], + products: [ + .library( + name: "Sparkle", + targets: ["Sparkle"]) + ], + targets: [ + .binaryTarget( + name: "Sparkle", + url: url, + checksum: checksum + ) + ] +) diff --git a/Package.swift b/Package.swift new file mode 100644 index 00000000..78115567 --- /dev/null +++ b/Package.swift @@ -0,0 +1,23 @@ +// swift-tools-version:5.3 +import PackageDescription + +let version = "2.0.0" +let checksum = "ced6b1d5691f948df49206eba9abe75fcabbef3dcfae685e8352c8df5d60ea22" +let url = "https://github.com/sparkle-project/Sparkle/releases/download/\(version)/Sparkle-SPM-\(version).zip" + +let package = Package( + name: "Sparkle", + platforms: [.macOS(.v10_11)], + products: [ + .library( + name: "Sparkle", + targets: ["Sparkle"]) + ], + targets: [ + .binaryTarget( + name: "Sparkle", + url: url, + checksum: checksum + ) + ] +) diff --git a/Sparkle.xcodeproj/xcshareddata/xcschemes/Distribution.xcscheme b/Sparkle.xcodeproj/xcshareddata/xcschemes/Distribution.xcscheme index a788391f..73c338ed 100644 --- a/Sparkle.xcodeproj/xcshareddata/xcschemes/Distribution.xcscheme +++ b/Sparkle.xcodeproj/xcshareddata/xcschemes/Distribution.xcscheme @@ -3,7 +3,7 @@ LastUpgradeVersion = "1200" version = "1.3">