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.podspec b/PKHUD.podspec index bb2c6c5..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.3.0' + 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 48d2a14..7b2c1ee 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 */, @@ -493,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"; @@ -571,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"; @@ -676,10 +680,12 @@ 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)"; SKIP_INSTALL = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) IS_FRAMEWORK_TARGET"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; @@ -701,10 +707,12 @@ 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)"; 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/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 diff --git a/PKHUD/PKHUDAssets.swift b/PKHUD/PKHUDAssets.swift index 2ecc43f..eb7b8de 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,10 @@ open class PKHUDAssets: NSObject { return UIImage() } } + +#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 diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..041dbbf --- /dev/null +++ b/Package.swift @@ -0,0 +1,26 @@ +// swift-tools-version:5.3 + +import PackageDescription + +let package = Package( + name: "PKHUD", + platforms: [ + .iOS(.v9), + ], + products: [ + .library( + name: "PKHUD", + targets: ["PKHUD"] + ), + ], + targets: [ + .target( + name: "PKHUD", + path: "PKHUD", + exclude: [ + "Info.plist", + ] + ), + ], + swiftLanguageVersions: [.v5] +) 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