Skip to content

Commit 670a5b0

Browse files
lstomberglstomber
andauthored
Support SwiftPM (#15)
Co-authored-by: Lucas Stomberg <[email protected]>
1 parent baf104b commit 670a5b0

File tree

3 files changed

+58
-2
lines changed

3 files changed

+58
-2
lines changed

Package.resolved

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// swift-tools-version:5.0
2+
3+
import PackageDescription
4+
5+
let pkg = Package(name: "PMKUIKit")
6+
pkg.products = [
7+
.library(name: "PMKUIKit", targets: ["PMKUIKit"]),
8+
]
9+
pkg.dependencies = [
10+
.package(url: "https://github.com/mxcl/PromiseKit.git", from: "6.8.3")
11+
]
12+
pkg.swiftLanguageVersions = [.v4, .v4_2, .v5]
13+
14+
let target: Target = .target(name: "PMKUIKit")
15+
target.path = "Sources"
16+
target.exclude = ["UIView", "UIViewController"].flatMap {
17+
["\($0)+AnyPromise.m", "\($0)+AnyPromise.h"]
18+
}
19+
target.exclude.append("PMKUIKit.h")
20+
21+
target.dependencies = [
22+
"PromiseKit"
23+
]
24+
25+
pkg.targets = [target]
26+
27+
pkg.platforms = [
28+
.iOS(.v8)
29+
]

Sources/UIImagePickerController+Promise.swift

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,21 @@ import UIKit
55

66
#if !os(tvOS)
77

8+
public struct AnimationOptions: OptionSet {
9+
public let rawValue: Int
10+
11+
public static let appear = AnimationOptions(rawValue: 1 << 1)
12+
public static let disappear = AnimationOptions(rawValue: 1 << 2)
13+
14+
public init(rawValue: Int) {
15+
self.rawValue = rawValue
16+
}
17+
}
18+
819
extension UIViewController {
920
#if swift(>=4.2)
1021
/// Presents the UIImagePickerController, resolving with the user action.
11-
public func promise(_ vc: UIImagePickerController, animate: PMKAnimationOptions = [.appear, .disappear], completion: (() -> Void)? = nil) -> Promise<[UIImagePickerController.InfoKey: Any]> {
22+
public func promise(_ vc: UIImagePickerController, animate: AnimationOptions = [.appear, .disappear], completion: (() -> Void)? = nil) -> Promise<[UIImagePickerController.InfoKey: Any]> {
1223
let animated = animate.contains(.appear)
1324
let proxy = UIImagePickerControllerProxy()
1425
vc.delegate = proxy
@@ -19,7 +30,7 @@ extension UIViewController {
1930
}
2031
#else
2132
/// Presents the UIImagePickerController, resolving with the user action.
22-
public func promise(_ vc: UIImagePickerController, animate: PMKAnimationOptions = [.appear, .disappear], completion: (() -> Void)? = nil) -> Promise<[String: Any]> {
33+
public func promise(_ vc: UIImagePickerController, animate: AnimationOptions = [.appear, .disappear], completion: (() -> Void)? = nil) -> Promise<[String: Any]> {
2334
let animated = animate.contains(.appear)
2435
let proxy = UIImagePickerControllerProxy()
2536
vc.delegate = proxy

0 commit comments

Comments
 (0)