From 5dd3953878889ad67b00747cf058d5de0f98c8a2 Mon Sep 17 00:00:00 2001 From: Artur Grigor Date: Wed, 5 Jun 2019 10:42:49 +0300 Subject: [PATCH 1/9] Added the SPM Package.swift file. --- Package.swift | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Package.swift diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..a90281e --- /dev/null +++ b/Package.swift @@ -0,0 +1,23 @@ +// swift-tools-version:5.0 + +import PackageDescription + +let package = Package( + name: "PKHUD", + platforms: [ + .iOS(.v8), + ], + products: [ + .library( + name: "PKHUD", + targets: ["PKHUD"] + ), + ], + targets: [ + .target( + name: "PKHUD", + path: "PKHUD" + ), + ], + swiftLanguageVersions: [.v5] +) From 6338cc0ec6dec4f3e89f4309d217400418899ea4 Mon Sep 17 00:00:00 2001 From: Artur Grigor Date: Wed, 5 Jun 2019 10:43:21 +0300 Subject: [PATCH 2/9] Ignore the SPM `.build` fodler and added the `Package.swift` and `PKHUD.podspec` files in Xcode. --- .gitignore | 1 + PKHUD.xcodeproj/project.pbxproj | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index f4f84f4..7790b50 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,4 @@ UserInterfaceState.xcuserstate fastlane/report.xml fastlane/test_output/report.html +.build diff --git a/PKHUD.xcodeproj/project.pbxproj b/PKHUD.xcodeproj/project.pbxproj index 48d2a14..457ea9f 100644 --- a/PKHUD.xcodeproj/project.pbxproj +++ b/PKHUD.xcodeproj/project.pbxproj @@ -112,6 +112,8 @@ F996324C19514FEF001F73CA /* WindowRootViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WindowRootViewController.swift; sourceTree = ""; }; F996325419514FF3001F73CA /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; F996325819515052001F73CA /* DemoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DemoViewController.swift; sourceTree = ""; }; + FEAB74E322A7A32F003F731F /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Package.swift; sourceTree = ""; }; + FEAB74E422A7A50B003F731F /* PKHUD.podspec */ = {isa = PBXFileReference; lastKnownFileType = text; path = PKHUD.podspec; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -178,6 +180,8 @@ F99631F319514FAC001F73CA = { isa = PBXGroup; children = ( + FEAB74E422A7A50B003F731F /* PKHUD.podspec */, + FEAB74E322A7A32F003F731F /* Package.swift */, F99631FE19514FAC001F73CA /* PKHUD Demo */, F996321F19514FD8001F73CA /* PKHUD */, 12CE19F21E25784D0062D873 /* PKHUDDemoUITests */, From 58f8cc6280e8206475d5a2ec15a0314a8c210615 Mon Sep 17 00:00:00 2001 From: Artur Grigor Date: Thu, 17 Sep 2020 13:01:06 +0300 Subject: [PATCH 3/9] Updated the SPM manifest to include the Images. --- Package.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Package.swift b/Package.swift index a90281e..e5fcb62 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.0 +// swift-tools-version:5.3 import PackageDescription @@ -16,7 +16,10 @@ let package = Package( targets: [ .target( name: "PKHUD", - path: "PKHUD" + path: "PKHUD", + resources: [ + .process("Images.xcassets") + ] ), ], swiftLanguageVersions: [.v5] From 5143ab31e4df89b0bb35283edfc63d9d3a2e03ea Mon Sep 17 00:00:00 2001 From: Artur Grigor Date: Thu, 17 Sep 2020 13:19:46 +0300 Subject: [PATCH 4/9] Exclude the `Info.plist` file from the SPM package. --- Package.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Package.swift b/Package.swift index e5fcb62..aeae9a8 100644 --- a/Package.swift +++ b/Package.swift @@ -17,8 +17,8 @@ let package = Package( .target( name: "PKHUD", path: "PKHUD", - resources: [ - .process("Images.xcassets") + exclude: [ + "Info.plist", ] ), ], From f385c5623ecc7db66c9891f0a4de75f89bda1095 Mon Sep 17 00:00:00 2001 From: Artur Grigor Date: Thu, 17 Sep 2020 13:22:02 +0300 Subject: [PATCH 5/9] Fix for the "The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99." warning. --- Package.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index aeae9a8..041dbbf 100644 --- a/Package.swift +++ b/Package.swift @@ -5,7 +5,7 @@ import PackageDescription let package = Package( name: "PKHUD", platforms: [ - .iOS(.v8), + .iOS(.v9), ], products: [ .library( From eed0c65e1810ed643c85168b2159652859b7de51 Mon Sep 17 00:00:00 2001 From: Artur Grigor Date: Thu, 17 Sep 2020 13:30:38 +0300 Subject: [PATCH 6/9] Added the `Bundle.module` support for loading the Images. --- PKHUD/PKHUDAssets.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/PKHUD/PKHUDAssets.swift b/PKHUD/PKHUDAssets.swift index 2ecc43f..2d3a6b6 100644 --- a/PKHUD/PKHUDAssets.swift +++ b/PKHUD/PKHUDAssets.swift @@ -19,7 +19,10 @@ open class PKHUDAssets: NSObject { internal class func bundledImage(named name: String) -> UIImage { let primaryBundle = Bundle(for: PKHUDAssets.self) - if let image = UIImage(named: name, in: primaryBundle, compatibleWith: nil) { + if let image = UIImage(named: name, in: .module, compatibleWith: nil) { + // Load image from SPM if available + return image + } else if let image = UIImage(named: name, in: primaryBundle, compatibleWith: nil) { // Load image in cases where PKHUD is directly integrated return image } else if @@ -34,3 +37,8 @@ open class PKHUDAssets: NSObject { return UIImage() } } + +private extension Bundle { + /// In packages a .module static var is automatically available, here we "create" one for the framework build. + static var module: Bundle { return Bundle(for: PKHUDAssets.self) } +} From 1e80c02fc3d246bbbc523aee0f4b3ceceb5f6df2 Mon Sep 17 00:00:00 2001 From: Artur Grigor Date: Thu, 17 Sep 2020 13:37:21 +0300 Subject: [PATCH 7/9] Include the `Bundle.module` support only when building the framework alone so we don't end up with SPM redeclaring it. --- PKHUD.xcodeproj/project.pbxproj | 4 +++- PKHUD/PKHUDAssets.swift | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/PKHUD.xcodeproj/project.pbxproj b/PKHUD.xcodeproj/project.pbxproj index 457ea9f..da9b580 100644 --- a/PKHUD.xcodeproj/project.pbxproj +++ b/PKHUD.xcodeproj/project.pbxproj @@ -497,7 +497,6 @@ MTL_ENABLE_DEBUG_INFO = YES; PRODUCT_BUNDLE_IDENTIFIER = NSExceptional.PKHUDDemoUITests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_SWIFT3_OBJC_INFERENCE = Default; SWIFT_VERSION = 4.2; TEST_TARGET_NAME = "PKHUD Demo"; @@ -575,6 +574,7 @@ METAL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; @@ -684,6 +684,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.NSExceptional.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) IS_FRAMEWORK_TARGET"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; @@ -709,6 +710,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.NSExceptional.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) IS_FRAMEWORK_TARGET"; SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; diff --git a/PKHUD/PKHUDAssets.swift b/PKHUD/PKHUDAssets.swift index 2d3a6b6..eb7b8de 100644 --- a/PKHUD/PKHUDAssets.swift +++ b/PKHUD/PKHUDAssets.swift @@ -38,7 +38,9 @@ open class PKHUDAssets: NSObject { } } +#if IS_FRAMEWORK_TARGET private extension Bundle { /// In packages a .module static var is automatically available, here we "create" one for the framework build. static var module: Bundle { return Bundle(for: PKHUDAssets.self) } } +#endif From eb373504aed8299c7eafd6c5e0a3326c6665e47d Mon Sep 17 00:00:00 2001 From: Artur Grigor Date: Thu, 17 Sep 2020 13:40:17 +0300 Subject: [PATCH 8/9] Bumped the project version. --- PKHUD.podspec | 2 +- PKHUD.xcodeproj/project.pbxproj | 2 ++ PKHUD/Info.plist | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/PKHUD.podspec b/PKHUD.podspec index 1af3180..6266e4d 100644 --- a/PKHUD.podspec +++ b/PKHUD.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = 'PKHUD' s.module_name = 'PKHUD' - s.version = '5.2.2' + s.version = '5.4.0' s.summary = 'A Swift 3 based reimplementation of the Apple HUD (Volume, Ringer, Rotation,…) for iOS 8 and up' s.homepage = 'https://github.com/pkluz/PKHUD' s.license = 'MIT' diff --git a/PKHUD.xcodeproj/project.pbxproj b/PKHUD.xcodeproj/project.pbxproj index da9b580..7b2c1ee 100644 --- a/PKHUD.xcodeproj/project.pbxproj +++ b/PKHUD.xcodeproj/project.pbxproj @@ -680,6 +680,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MARKETING_VERSION = 5.4.0; METAL_ENABLE_DEBUG_INFO = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.NSExceptional.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -706,6 +707,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MARKETING_VERSION = 5.4.0; METAL_ENABLE_DEBUG_INFO = NO; PRODUCT_BUNDLE_IDENTIFIER = "com.NSExceptional.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/PKHUD/Info.plist b/PKHUD/Info.plist index 6f76a1c..72caab8 100644 --- a/PKHUD/Info.plist +++ b/PKHUD/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 5.2.2 + $(MARKETING_VERSION) CFBundleSignature ???? CFBundleVersion From 01e741b8fd4929dd78ef976e15626906c95a8a52 Mon Sep 17 00:00:00 2001 From: Artur Grigor Date: Thu, 17 Sep 2020 13:45:36 +0300 Subject: [PATCH 9/9] Added the SPM compatible badge and updated the installation docs. --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index f6fe6be..8702957 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![License](https://img.shields.io/cocoapods/l/PKHUD.svg?style=flat)](https://cocoapods.org/pods/PKHUD) [![Platform](https://img.shields.io/cocoapods/p/PKHUD.svg?style=flat)](http://cocoadocs.org/docsets/PKHUD/3.2.1/) [![CocoaPod](https://img.shields.io/cocoapods/v/PKHUD.svg?style=flat)](https://cocoapods.org/pods/PKHUD) +[![SPM compatible](https://img.shields.io/badge/SPM-compatible-4BC51D.svg?style=flat)](https://swift.org/package-manager/) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) ![PKHUD - Swift and easy](https://raw.githubusercontent.com/pkluz/PKHUD/master/README_hero.png) @@ -61,6 +62,13 @@ github "pkluz/PKHUD" ~> 4.0 Run `carthage update` to build the framework and drag the built `PKHUD.framework` into your Xcode project. +### Swift Package Manager + +To install using Swift Package Manager, add this to the `dependencies:` section in your Package.swift file: +```swift +.package(url: "https://github.com/pkluz/PKHUD.git", .upToNextMinor(from: "5.4.0")), +``` + ## How To After adding the framework to your project, you need to import the module