Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SwiftPM, Xcode11 and iOS 13 support support against develop branch #51

Merged
merged 7 commits into from
Aug 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Closures.podspec.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
},
"source_files": "Xcode/Closures/Source",
"documentation_url": "https://vhesener.github.io/Closures/",
"description": "Closures is an iOS Framework that adds closure handlers to many of the popular\nUIKit and Foundation classes. Although this framework is a substitute for \nsome Cocoa Touch design patterns, such as Delegation and Data Sources, and \nTarget-Action, the authors make no claim regarding which is a better way to \naccomplish the same type of task. Most of the time it is a matter of style, \npreference, or convenience that will determine if any of these closure extensions \nare beneficial.\n\nWhether you’re a functional purist, dislike a particular API, or simply just \nwant to organize your code a little bit, you might enjoy using this library."
}
"description": "Closures is an iOS Framework that adds closure handlers to many of the popular\nUIKit and Foundation classes. Although this framework is a substitute for \nsome Cocoa Touch design patterns, such as Delegation and Data Sources, and \nTarget-Action, the authors make no claim regarding which is a better way to \naccomplish the same type of task. Most of the time it is a matter of style, \npreference, or convenience that will determine if any of these closure extensions \nare beneficial.\n\nWhether you’re a functional purist, dislike a particular API, or simply just \nwant to organize your code a little bit, you might enjoy using this library.",
"pushed_with_swift_version": "5.0"
}
14 changes: 14 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// swift-tools-version:5.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription

let package = Package(
name: "Closures",
products: [
.library(name: "Closures", targets: ["Closures"])
],
dependencies: [],
targets: [
.target(name: "Closures", path: "Xcode/Closures")
]
)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Whether you're a functional purist, dislike a particular API, or simply just want to organize your code a little bit, you might enjoy using this library.

> ***<sub>note</sub>*** <br/>
> `Closures` currently only supports projects written in **Swift 4.0**+.
> `Closures` currently only supports projects written in **Swift 5.0**+.

***
## [Usage Overview](#usage-overview)
Expand Down
6 changes: 3 additions & 3 deletions Xcode/Closures.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0800;
LastUpgradeCheck = 1020;
LastUpgradeCheck = 1100;
ORGANIZATIONNAME = "Your Mom";
TargetAttributes = {
3F7620DD1D849B5000E17BF5 = {
Expand Down Expand Up @@ -426,7 +426,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_IDENTITY = "";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
Expand All @@ -449,7 +449,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_IDENTITY = "";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
28 changes: 12 additions & 16 deletions Xcode/Closures.xcodeproj/xcshareddata/xcschemes/Closures.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
LastUpgradeVersion = "1100"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,8 +26,17 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
codeCoverageEnabled = "YES"
shouldUseLaunchSchemeArgsEnv = "YES">
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3F7620DD1D849B5000E17BF5"
BuildableName = "Closures.framework"
BlueprintName = "Closures"
ReferencedContainer = "container:Closures.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -40,17 +49,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3F7620DD1D849B5000E17BF5"
BuildableName = "Closures.framework"
BlueprintName = "Closures"
ReferencedContainer = "container:Closures.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -71,8 +69,6 @@
ReferencedContainer = "container:Closures.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
4 changes: 4 additions & 0 deletions Xcode/Closures/Source/Core.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,18 @@ import Foundation
protocol DelegateProtocol: class {
}

@available(iOS 9.0, *)
public protocol DelegatorProtocol: class {
/**
Clears any delegates/datasources that were assigned by the `Closures`
framework for this object. This cleans up memory as well as sets the
delegate/datasource properties to nil.
*/
@available(iOS 9.0, *)
func clearClosureDelegates()
}

@available(iOS 9.0, *)
class DelegateWrapper<Delegator: DelegatorProtocol, Delegate: DelegateProtocol>: NSObject {
weak var delegator: Delegator?
let delegate: Delegate
Expand Down Expand Up @@ -75,6 +78,7 @@ class DelegateWrapper<Delegator: DelegatorProtocol, Delegate: DelegateProtocol>:
}
}

@available(iOS 9.0, *)
public static func update(_ delegator: Delegator,
delegate: @autoclosure () -> Delegate,
delegates: inout Set<DelegateWrapper<Delegator,Delegate>>,
Expand Down
4 changes: 4 additions & 0 deletions Xcode/Closures/Source/UICollectionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import UIKit
/// :nodoc:
private let jzyBug = 0 // Prevent the license header from showing up in Jazzy Docs for UICollectionView

@available(iOS 9.0, *)
extension UICollectionView {
// MARK: Common Array Usage
/**
Expand Down Expand Up @@ -110,6 +111,7 @@ extension UICollectionView {
}
}

@available(iOS 9.0, *)
class CollectionViewDelegate: ScrollViewDelegate, UICollectionViewDelegateFlowLayout, UICollectionViewDataSource {
fileprivate static var delegates = Set<DelegateWrapper<UICollectionView, CollectionViewDelegate>>()

Expand Down Expand Up @@ -355,6 +357,7 @@ class CollectionViewDelegate: ScrollViewDelegate, UICollectionViewDelegateFlowLa
}
}

@available(iOS 9.0, *)
extension UICollectionView {
// MARK: Delegate and DataSource Overrides
/**
Expand Down Expand Up @@ -755,6 +758,7 @@ extension UICollectionView {
}
}

@available(iOS 9.0, *)
extension UICollectionView {
@discardableResult
@objc override func update(handler: (_ delegate: CollectionViewDelegate) -> Void) -> Self {
Expand Down
15 changes: 15 additions & 0 deletions Xcode/Closures/Source/UIControl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import UIKit

@available(iOS 9.0, *)
fileprivate extension UIControl {
func _onChange<ControlType, ValueType>(
callerHandler: @escaping (_ value: ValueType) -> (Void),
Expand All @@ -33,6 +34,7 @@ fileprivate extension UIControl {
}
}

@available(iOS 9.0, *)
extension UIControl {
public typealias EventHandler = (_ sender: UIControl, _ forEvent: UIEvent?) -> Void
/**
Expand Down Expand Up @@ -166,6 +168,7 @@ extension UIControl {
}
}

@available(iOS 9.0, *)
extension UIControl {
/**
Provides the proper internal selector to call for the type of UIControlEvent
Expand Down Expand Up @@ -223,6 +226,7 @@ extension UIControl {
}
}

@available(iOS 9.0, *)
extension UIButton {
// MARK: Common Events
/**
Expand Down Expand Up @@ -251,6 +255,7 @@ extension UIButton {
}
}

@available(iOS 9.0, *)
extension UITextField {
// MARK: Common Events
/**
Expand Down Expand Up @@ -337,6 +342,7 @@ extension UITextField {
}
}

@available(iOS 9.0, *)
extension UITextField {
// MARK: Delegate Overrides
/**
Expand Down Expand Up @@ -457,6 +463,7 @@ extension UITextField {
}
}

@available(iOS 9.0, *)
extension UITextField: DelegatorProtocol {
@discardableResult
fileprivate func update(handler: (_ delegate: TextFieldDelegate) -> Void) -> Self {
Expand Down Expand Up @@ -488,11 +495,13 @@ extension UITextField: DelegatorProtocol {
}

#if DEBUG
@available(iOS 9.0, *)
var textFieldDelegates: Set<AnyHashable> {
return TextFieldDelegate.delegates
}
#endif

@available(iOS 9.0, *)
fileprivate final class TextFieldDelegate: NSObject, UITextFieldDelegate, DelegateProtocol {
fileprivate static var delegates = Set<DelegateWrapper<UITextField, TextFieldDelegate>>()

Expand Down Expand Up @@ -557,6 +566,7 @@ fileprivate final class TextFieldDelegate: NSObject, UITextFieldDelegate, Delega
}
}

@available(iOS 9.0, *)
extension UISwitch {
// MARK: Common Events
/**
Expand All @@ -576,6 +586,7 @@ extension UISwitch {
}
}

@available(iOS 9.0, *)
extension UISlider {
// MARK: Common Events
/**
Expand All @@ -595,6 +606,7 @@ extension UISlider {
}
}

@available(iOS 9.0, *)
extension UISegmentedControl {
// MARK: Common Events
/**
Expand All @@ -614,6 +626,7 @@ extension UISegmentedControl {
}
}

@available(iOS 9.0, *)
extension UIStepper {
// MARK: Common Events
/**
Expand All @@ -633,6 +646,7 @@ extension UIStepper {
}
}

@available(iOS 9.0, *)
extension UIPageControl {
// MARK: Common Events
/**
Expand All @@ -652,6 +666,7 @@ extension UIPageControl {
}
}

@available(iOS 9.0, *)
extension UIDatePicker {
// MARK: Common Events
/**
Expand Down
3 changes: 3 additions & 0 deletions Xcode/Closures/Source/UIGestureRecognizer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ extension UIView {
}
}

@available(iOS 9.0, *)
fileprivate final class GestureRecognizerDelegate: NSObject, UIGestureRecognizerDelegate, DelegateProtocol {
static var delegates = Set<DelegateWrapper<UIGestureRecognizer, GestureRecognizerDelegate>>()

Expand Down Expand Up @@ -396,6 +397,7 @@ fileprivate final class GestureRecognizerDelegate: NSObject, UIGestureRecognizer
}
}

@available(iOS 9.0, *)
extension UIGestureRecognizer {
// MARK: Delegate Overrides
/**
Expand Down Expand Up @@ -471,6 +473,7 @@ extension UIGestureRecognizer {
}
}

@available(iOS 9.0, *)
extension UIGestureRecognizer: DelegatorProtocol {
@discardableResult
fileprivate func update(handler: (_ delegate: GestureRecognizerDelegate) -> Void) -> Self {
Expand Down
7 changes: 7 additions & 0 deletions Xcode/Closures/Source/UIImagePickerController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import UIKit
import MobileCoreServices
import PhotosUI

@available(iOS 9.0, *)
fileprivate final class ImagePickerControllerDelegate: NSObject, UIImagePickerControllerDelegate, UINavigationControllerDelegate, DelegateProtocol {
static var delegates = Set<DelegateWrapper<UIImagePickerController, ImagePickerControllerDelegate>>()

Expand Down Expand Up @@ -49,6 +50,7 @@ fileprivate final class ImagePickerControllerDelegate: NSObject, UIImagePickerCo
}
}

@available(iOS 9.0, *)
extension UIImagePickerController {
// MARK: Convenient Presenting
/**
Expand Down Expand Up @@ -169,6 +171,7 @@ extension UIImagePickerController {
}
}

@available(iOS 9.0, *)
extension UIImagePickerController {
// MARK: Delegate Overrides
/**
Expand Down Expand Up @@ -196,6 +199,7 @@ extension UIImagePickerController {
}
}

@available(iOS 9.0, *)
extension UIImagePickerController {
// MARK: Helper Types
/**
Expand Down Expand Up @@ -317,13 +321,15 @@ extension UIImagePickerController {
}
}

@available(iOS 9.0, *)
extension UIImagePickerController.MediaFilter: ExpressibleByIntegerLiteral {
/// :nodoc:
public init(integerLiteral value: Int) {
self.init(rawValue: value)
}
}

@available(iOS 9.0, *)
fileprivate extension CFString {
var mediaFilter: UIImagePickerController.MediaFilter {
switch self {
Expand All @@ -337,6 +343,7 @@ fileprivate extension CFString {
}
}

@available(iOS 9.0, *)
extension UIImagePickerController: DelegatorProtocol {
@discardableResult
fileprivate func update(handler: (_ delegate: ImagePickerControllerDelegate) -> Void) -> Self {
Expand Down
Loading