Skip to content

Commit

Permalink
Merge pull request #277 from arturgrigor/master
Browse files Browse the repository at this point in the history
SPM support
  • Loading branch information
PGLongo committed Sep 17, 2020
2 parents be74f5e + 7a34370 commit 8fd26f2
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ UserInterfaceState.xcuserstate
fastlane/report.xml

fastlane/test_output/report.html
.build
2 changes: 1 addition & 1 deletion PKHUD.podspec
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
10 changes: 9 additions & 1 deletion PKHUD.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@
F996324C19514FEF001F73CA /* WindowRootViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WindowRootViewController.swift; sourceTree = "<group>"; };
F996325419514FF3001F73CA /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
F996325819515052001F73CA /* DemoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DemoViewController.swift; sourceTree = "<group>"; };
FEAB74E322A7A32F003F731F /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Package.swift; sourceTree = "<group>"; };
FEAB74E422A7A50B003F731F /* PKHUD.podspec */ = {isa = PBXFileReference; lastKnownFileType = text; path = PKHUD.podspec; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -178,6 +180,8 @@
F99631F319514FAC001F73CA = {
isa = PBXGroup;
children = (
FEAB74E422A7A50B003F731F /* PKHUD.podspec */,
FEAB74E322A7A32F003F731F /* Package.swift */,
F99631FE19514FAC001F73CA /* PKHUD Demo */,
F996321F19514FD8001F73CA /* PKHUD */,
12CE19F21E25784D0062D873 /* PKHUDDemoUITests */,
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand All @@ -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 = "";
Expand Down
2 changes: 1 addition & 1 deletion PKHUD/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>5.2.2</string>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
12 changes: 11 additions & 1 deletion PKHUD/PKHUDAssets.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
26 changes: 26 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -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]
)
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8fd26f2

Please sign in to comment.