Skip to content

Commit c94d5b2

Browse files
committed
PMK 5.0.0
PMK5 just won’t build with Xcode 8.1 in release Dropping 8.0 as well then even though that worked.
1 parent 317136c commit c94d5b2

13 files changed

+33
-307
lines changed

.travis.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ matrix:
2121
- {osx_image: xcode8.2, env: 'Sw=3.0 Pt=iOS Dn="OS=10.2,name=iPhone SE"'}
2222
- {osx_image: xcode8.2, env: 'Sw=3.0 Pt=tvOS Dn="OS=10.1,name=Apple TV 1080p"'}
2323

24-
- {osx_image: xcode8.1, env: 'Sw=3.0 Pt=iOS Dn="OS=10.1,name=iPhone SE"'}
25-
- {osx_image: xcode8.1, env: 'Sw=3.0 Pt=tvOS Dn="OS=10.0,name=Apple TV 1080p"'}
26-
27-
- {osx_image: xcode8, env: 'Sw=3.0 Pt=iOS Dn="OS=10.0,name=iPhone SE"'}
28-
- {osx_image: xcode8, env: 'Sw=3.0 Pt=tvOS Dn="OS=10.0,name=Apple TV 1080p"'}
29-
3024
install:
3125
- carthage bootstrap --platform $Pt
3226
script:

Cartfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
github "mxcl/PromiseKit" ~> 4.0
1+
github "mxcl/PromiseKit" ~> 5.0

Cartfile.resolved

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github "mxcl/PromiseKit" "5.0.0-beta.5"

PMKUIKit.xcodeproj/project.pbxproj

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,13 @@
1010
6304D6FE1D5F986A00CE6C99 /* PMKUIKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 6304D6FD1D5F986A00CE6C99 /* PMKUIKit.h */; settings = {ATTRIBUTES = (Public, ); }; };
1111
630B2E161D5D0B3200DC10E9 /* TestUIImagePickerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 630B2DF71D5D0AD400DC10E9 /* TestUIImagePickerController.swift */; };
1212
6332142B1D83CD17009F67CE /* TestUIView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6332142A1D83CD17009F67CE /* TestUIView.swift */; };
13-
637E2C7D1D5C2E0B0043E370 /* PMKAlertController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 637E2C701D5C2E0B0043E370 /* PMKAlertController.swift */; };
1413
637E2C841D5C2E0B0043E370 /* UIView+AnyPromise.h in Headers */ = {isa = PBXBuildFile; fileRef = 637E2C771D5C2E0B0043E370 /* UIView+AnyPromise.h */; settings = {ATTRIBUTES = (Public, ); }; };
1514
637E2C851D5C2E0B0043E370 /* UIView+AnyPromise.m in Sources */ = {isa = PBXBuildFile; fileRef = 637E2C781D5C2E0B0043E370 /* UIView+AnyPromise.m */; };
1615
637E2C861D5C2E0B0043E370 /* UIView+Promise.swift in Sources */ = {isa = PBXBuildFile; fileRef = 637E2C791D5C2E0B0043E370 /* UIView+Promise.swift */; };
1716
637E2C871D5C2E0B0043E370 /* UIViewController+AnyPromise.h in Headers */ = {isa = PBXBuildFile; fileRef = 637E2C7A1D5C2E0B0043E370 /* UIViewController+AnyPromise.h */; settings = {ATTRIBUTES = (Public, ); }; };
1817
637E2C881D5C2E0B0043E370 /* UIViewController+AnyPromise.m in Sources */ = {isa = PBXBuildFile; fileRef = 637E2C7B1D5C2E0B0043E370 /* UIViewController+AnyPromise.m */; };
19-
637E2C891D5C2E0B0043E370 /* UIViewController+Promise.swift in Sources */ = {isa = PBXBuildFile; fileRef = 637E2C7C1D5C2E0B0043E370 /* UIViewController+Promise.swift */; };
2018
637E2C951D5C2E720043E370 /* TestUIImagePickerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 637E2C8E1D5C2E720043E370 /* TestUIImagePickerController.swift */; };
2119
637E2C961D5C2E720043E370 /* TestUIViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 637E2C8F1D5C2E720043E370 /* TestUIViewController.m */; };
22-
637E2C971D5C2E720043E370 /* TestUIViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 637E2C901D5C2E720043E370 /* TestUIViewController.swift */; };
2320
637E2C9B1D5C2F600043E370 /* infrastructure.swift in Sources */ = {isa = PBXBuildFile; fileRef = 637E2C9A1D5C2F600043E370 /* infrastructure.swift */; };
2421
63A686811D88E93300D1C66B /* UIImagePickerController+Promise.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63A6867E1D88E93300D1C66B /* UIImagePickerController+Promise.swift */; };
2522
63C7FFF71D5C020D003BAE60 /* PMKUIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 63C7FFA71D5BEE09003BAE60 /* PMKUIKit.framework */; };
@@ -81,16 +78,13 @@
8178
630B2DF71D5D0AD400DC10E9 /* TestUIImagePickerController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TestUIImagePickerController.swift; path = UITests/TestUIImagePickerController.swift; sourceTree = "<group>"; };
8279
630B2E131D5D0AF500DC10E9 /* PMKUIUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PMKUIUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
8380
6332142A1D83CD17009F67CE /* TestUIView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TestUIView.swift; path = Tests/TestUIView.swift; sourceTree = SOURCE_ROOT; };
84-
637E2C701D5C2E0B0043E370 /* PMKAlertController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PMKAlertController.swift; path = Sources/PMKAlertController.swift; sourceTree = SOURCE_ROOT; };
8581
637E2C771D5C2E0B0043E370 /* UIView+AnyPromise.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIView+AnyPromise.h"; path = "Sources/UIView+AnyPromise.h"; sourceTree = SOURCE_ROOT; };
8682
637E2C781D5C2E0B0043E370 /* UIView+AnyPromise.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIView+AnyPromise.m"; path = "Sources/UIView+AnyPromise.m"; sourceTree = SOURCE_ROOT; };
8783
637E2C791D5C2E0B0043E370 /* UIView+Promise.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "UIView+Promise.swift"; path = "Sources/UIView+Promise.swift"; sourceTree = SOURCE_ROOT; };
8884
637E2C7A1D5C2E0B0043E370 /* UIViewController+AnyPromise.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIViewController+AnyPromise.h"; path = "Sources/UIViewController+AnyPromise.h"; sourceTree = SOURCE_ROOT; };
8985
637E2C7B1D5C2E0B0043E370 /* UIViewController+AnyPromise.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIViewController+AnyPromise.m"; path = "Sources/UIViewController+AnyPromise.m"; sourceTree = SOURCE_ROOT; };
90-
637E2C7C1D5C2E0B0043E370 /* UIViewController+Promise.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "UIViewController+Promise.swift"; path = "Sources/UIViewController+Promise.swift"; sourceTree = SOURCE_ROOT; };
9186
637E2C8E1D5C2E720043E370 /* TestUIImagePickerController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TestUIImagePickerController.swift; path = Tests/TestUIImagePickerController.swift; sourceTree = SOURCE_ROOT; };
9287
637E2C8F1D5C2E720043E370 /* TestUIViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TestUIViewController.m; path = Tests/TestUIViewController.m; sourceTree = SOURCE_ROOT; };
93-
637E2C901D5C2E720043E370 /* TestUIViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TestUIViewController.swift; path = Tests/TestUIViewController.swift; sourceTree = SOURCE_ROOT; };
9488
637E2C9A1D5C2F600043E370 /* infrastructure.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = infrastructure.swift; path = Tests/infrastructure.swift; sourceTree = SOURCE_ROOT; };
9589
63A6867E1D88E93300D1C66B /* UIImagePickerController+Promise.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "UIImagePickerController+Promise.swift"; path = "Sources/UIImagePickerController+Promise.swift"; sourceTree = SOURCE_ROOT; };
9690
63C700091D5C0253003BAE60 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@@ -173,13 +167,11 @@
173167
isa = PBXGroup;
174168
children = (
175169
6304D6FD1D5F986A00CE6C99 /* PMKUIKit.h */,
176-
637E2C701D5C2E0B0043E370 /* PMKAlertController.swift */,
177170
637E2C771D5C2E0B0043E370 /* UIView+AnyPromise.h */,
178171
637E2C781D5C2E0B0043E370 /* UIView+AnyPromise.m */,
179172
637E2C791D5C2E0B0043E370 /* UIView+Promise.swift */,
180173
637E2C7A1D5C2E0B0043E370 /* UIViewController+AnyPromise.h */,
181174
637E2C7B1D5C2E0B0043E370 /* UIViewController+AnyPromise.m */,
182-
637E2C7C1D5C2E0B0043E370 /* UIViewController+Promise.swift */,
183175
63A6867E1D88E93300D1C66B /* UIImagePickerController+Promise.swift */,
184176
);
185177
path = Sources;
@@ -190,7 +182,6 @@
190182
children = (
191183
637E2C8E1D5C2E720043E370 /* TestUIImagePickerController.swift */,
192184
637E2C8F1D5C2E720043E370 /* TestUIViewController.m */,
193-
637E2C901D5C2E720043E370 /* TestUIViewController.swift */,
194185
6332142A1D83CD17009F67CE /* TestUIView.swift */,
195186
637E2C9A1D5C2F600043E370 /* infrastructure.swift */,
196187
);
@@ -397,9 +388,7 @@
397388
buildActionMask = 2147483647;
398389
files = (
399390
63A686811D88E93300D1C66B /* UIImagePickerController+Promise.swift in Sources */,
400-
637E2C7D1D5C2E0B0043E370 /* PMKAlertController.swift in Sources */,
401391
637E2C861D5C2E0B0043E370 /* UIView+Promise.swift in Sources */,
402-
637E2C891D5C2E0B0043E370 /* UIViewController+Promise.swift in Sources */,
403392
637E2C851D5C2E0B0043E370 /* UIView+AnyPromise.m in Sources */,
404393
637E2C881D5C2E0B0043E370 /* UIViewController+AnyPromise.m in Sources */,
405394
);
@@ -410,7 +399,6 @@
410399
buildActionMask = 2147483647;
411400
files = (
412401
637E2C951D5C2E720043E370 /* TestUIImagePickerController.swift in Sources */,
413-
637E2C971D5C2E720043E370 /* TestUIViewController.swift in Sources */,
414402
637E2C961D5C2E720043E370 /* TestUIViewController.m in Sources */,
415403
637E2C9B1D5C2F600043E370 /* infrastructure.swift in Sources */,
416404
6332142B1D83CD17009F67CE /* TestUIView.swift in Sources */,

Sources/PMKUIKit.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
#import "UIView+AnyPromise.h"
22
#import "UIViewController+AnyPromise.h"
3+
4+
typedef NS_OPTIONS(NSInteger, PMKAnimationOptions) {
5+
PMKAnimationOptionsNone = 1 << 0,
6+
PMKAnimationOptionsAppear = 1 << 1,
7+
PMKAnimationOptionsDisappear = 1 << 2,
8+
};

Sources/UIImagePickerController+Promise.swift

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,39 @@
1-
import UIKit
2-
#if !COCOAPODS
1+
#if !PMKCocoaPods
32
import PromiseKit
43
#endif
4+
import UIKit
55

66
#if !os(tvOS)
77

88
extension UIViewController {
9-
@available(*, deprecated: 3.4, renamed: "promise(_:animate:fulfills:completion:)")
10-
public func promiseViewController(_ vc: UIImagePickerController, animated: Bool = true, completion: (() -> Void)? = nil) -> Promise<UIImage> {
11-
return promise(vc, animate: animated ? [.appear, .disappear] : [], completion: completion)
12-
}
13-
14-
@available(*, deprecated: 3.4, renamed: "promise(_:animate:fulfills:completion:)")
15-
public func promiseViewController(_ vc: UIImagePickerController, animated: Bool = true, completion: (() -> Void)? = nil) -> Promise<[String: AnyObject]> {
16-
return promise(vc, animate: animated ? [.appear, .disappear] : [], completion: completion)
17-
}
18-
19-
/// Presents the UIImagePickerController, resolving with the user action.
20-
public func promise(_ vc: UIImagePickerController, animate: PMKAnimationOptions = [.appear, .disappear], completion: (() -> Void)? = nil) -> Promise<UIImage> {
21-
let animated = animate.contains(.appear)
22-
let proxy = UIImagePickerControllerProxy()
23-
vc.delegate = proxy
24-
vc.mediaTypes = ["public.image"] // this promise can only resolve with a UIImage
25-
present(vc, animated: animated, completion: completion)
26-
return proxy.promise.then(on: zalgo) { info -> UIImage in
27-
if let img = info[UIImagePickerControllerEditedImage] as? UIImage {
28-
return img
29-
}
30-
if let img = info[UIImagePickerControllerOriginalImage] as? UIImage {
31-
return img
32-
}
33-
throw PMKError.noImageFound
34-
}.always {
35-
vc.presentingViewController?.dismiss(animated: animated, completion: nil)
36-
}
37-
}
38-
399
/// Presents the UIImagePickerController, resolving with the user action.
4010
public func promise(_ vc: UIImagePickerController, animate: PMKAnimationOptions = [.appear, .disappear], completion: (() -> Void)? = nil) -> Promise<[String: Any]> {
4111
let animated = animate.contains(.appear)
4212
let proxy = UIImagePickerControllerProxy()
4313
vc.delegate = proxy
4414
present(vc, animated: animated, completion: completion)
45-
return proxy.promise.always {
15+
return proxy.promise.ensure {
4616
vc.presentingViewController?.dismiss(animated: animated, completion: nil)
4717
}
4818
}
4919
}
5020

5121
@objc private class UIImagePickerControllerProxy: NSObject, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
52-
let (promise, fulfill, reject) = Promise<[String : Any]>.pending()
22+
let (promise, seal) = Promise<[String: Any]>.pending()
5323
var retainCycle: AnyObject?
5424

5525
required override init() {
5626
super.init()
5727
retainCycle = self
5828
}
5929

60-
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
61-
fulfill(info)
30+
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String: Any]) {
31+
seal.fulfill(info)
6232
retainCycle = nil
6333
}
6434

6535
func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
66-
reject(UIImagePickerController.PMKError.cancelled)
36+
seal.reject(UIImagePickerController.PMKError.cancelled)
6737
retainCycle = nil
6838
}
6939
}

Sources/UIView+Promise.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import UIKit.UIView
2-
#if !COCOAPODS
2+
#if !PMKCocoaPods
33
import PromiseKit
44
#endif
55

@@ -40,7 +40,11 @@ extension UIView {
4040
- Returns: A promise that fulfills with a boolean NSNumber indicating
4141
whether or not the animations actually finished.
4242
*/
43-
public class func promise(animateWithDuration duration: TimeInterval, delay: TimeInterval = 0, options: UIViewAnimationOptions = [], animations: @escaping () -> Void) -> Promise<Bool> {
44-
return PromiseKit.wrap { animate(withDuration: duration, delay: delay, options: options, animations: animations, completion: $0) }
43+
public class func animate(_: PMKNamespacer, duration: TimeInterval, delay: TimeInterval = 0, options: UIViewAnimationOptions = [], animations: @escaping () -> Void) -> Guarantee<Bool> {
44+
return Guarantee(.pending) { animate(withDuration: duration, delay: delay, options: options, animations: animations, completion: $0) }
45+
}
46+
47+
public class func animate(_: PMKNamespacer, duration: TimeInterval, delay: TimeInterval, usingSpringWithDamping damping: CGFloat, initialSpringVelocity: CGFloat, options: UIViewAnimationOptions = [], animations: @escaping () -> Void) -> Guarantee<Bool> {
48+
return Guarantee(.pending) { animate(withDuration: duration, delay: delay, usingSpringWithDamping: damping, initialSpringVelocity: initialSpringVelocity, options: options, animations: animations, completion: $0) }
4549
}
4650
}

Sources/UIViewController+AnyPromise.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ - (AnyPromise *)promiseViewController:(UIViewController *)vc animated:(BOOL)anim
4242
promise = [[AnyPromise alloc] initWithResolver:&resolve];
4343
[vc setValue:^(NSInteger result){
4444
if (result == 0) {
45-
resolve([NSError cancelledError]);
45+
resolve([NSError errorWithDomain:NSCocoaErrorDomain code:NSUserCancelledError userInfo:nil]);
4646
} else {
4747
resolve(@(result));
4848
}
@@ -78,7 +78,7 @@ - (AnyPromise *)promiseViewController:(UIViewController *)vc animated:(BOOL)anim
7878

7979
[self presentViewController:vc2present animated:animated completion:block];
8080

81-
promise.always(^{
81+
promise.ensure(^{
8282
[vc2present.presentingViewController dismissViewControllerAnimated:animated completion:nil];
8383
});
8484

@@ -104,7 +104,7 @@ - (void)mailComposeController:(id)controller didFinishWithResult:(int)result err
104104
if (error != nil) {
105105
resolve(error);
106106
} else if (result == 0) {
107-
resolve([NSError cancelledError]);
107+
resolve([NSError errorWithDomain:NSCocoaErrorDomain code:NSUserCancelledError userInfo:nil]);
108108
} else {
109109
resolve(@(result));
110110
}

Sources/UIViewController+Promise.swift

Lines changed: 0 additions & 111 deletions
This file was deleted.

0 commit comments

Comments
 (0)