diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0dc5c83 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.swiftpm \ No newline at end of file diff --git a/CFAlertViewController/CFAlertViewController.swift b/CFAlertViewController/CFAlertViewController.swift index 7ba2563..df7a29f 100644 --- a/CFAlertViewController/CFAlertViewController.swift +++ b/CFAlertViewController/CFAlertViewController.swift @@ -293,11 +293,8 @@ open class CFAlertViewController: UIViewController { footerView: UIView?, didDismissAlertHandler dismiss: CFAlertViewControllerDismissBlock?) { - // Get Current Bundle - let bundle = Bundle(for: CFAlertViewController.self) - // Create New Instance Of Alert Controller - self.init(nibName: "CFAlertViewController", bundle: bundle) + self.init(nibName: "CFAlertViewController", bundle: .current) // Assign Properties self.preferredStyle = preferredStyle @@ -364,9 +361,9 @@ open class CFAlertViewController: UIViewController { NotificationCenter.default.addObserver(self, selector: #selector(textViewOrTextFieldDidBeginEditing(_:)), name: UITextView.textDidBeginEditingNotification, object: nil) // Register Cells For Table - let actionCellNib = UINib(nibName: CFAlertActionTableViewCell.identifier(), bundle: Bundle(for: CFAlertActionTableViewCell.self)) + let actionCellNib = UINib(nibName: CFAlertActionTableViewCell.identifier(), bundle: .current) tableView?.register(actionCellNib, forCellReuseIdentifier: CFAlertActionTableViewCell.identifier()) - let titleSubtitleCellNib = UINib(nibName: CFAlertTitleSubtitleTableViewCell.identifier(), bundle: Bundle(for: CFAlertTitleSubtitleTableViewCell.self)) + let titleSubtitleCellNib = UINib(nibName: CFAlertTitleSubtitleTableViewCell.identifier(), bundle: .current) tableView?.register(titleSubtitleCellNib, forCellReuseIdentifier: CFAlertTitleSubtitleTableViewCell.identifier()) // Add Key Value Observer @@ -837,4 +834,13 @@ extension NSObject { } } - +// MARK: - Bundle Extension +extension Bundle { + static var current: Bundle? { + #if SWIFT_PACKAGE + return .module + #else + return Bundle(for: CFAlertViewController.self) + #endif + } +} diff --git a/CFAlertViewController/Cells/CFAlertActionTableViewCell.swift b/CFAlertViewController/Cells/CFAlertActionTableViewCell.swift index 8fc301e..aa9c8ac 100644 --- a/CFAlertViewController/Cells/CFAlertActionTableViewCell.swift +++ b/CFAlertViewController/Cells/CFAlertActionTableViewCell.swift @@ -9,7 +9,7 @@ import UIKit -public protocol CFAlertActionTableViewCellDelegate: class { +public protocol CFAlertActionTableViewCellDelegate: AnyObject { func alertActionCell(_ cell: CFAlertActionTableViewCell, didClickAction action: CFAlertAction?) } diff --git a/CFAlertViewController/Transitions/Base/CFAlertBaseInteractiveTransition.swift b/CFAlertViewController/Transitions/Base/CFAlertBaseInteractiveTransition.swift index c36e588..744d895 100644 --- a/CFAlertViewController/Transitions/Base/CFAlertBaseInteractiveTransition.swift +++ b/CFAlertViewController/Transitions/Base/CFAlertBaseInteractiveTransition.swift @@ -9,7 +9,7 @@ import UIKit -@objc public protocol CFAlertInteractiveTransitionDelegate: class { +@objc public protocol CFAlertInteractiveTransitionDelegate: AnyObject { @objc optional func alertViewControllerTransitionWillBegin(_ transition: CFAlertBaseInteractiveTransition) @objc optional func alertViewControllerTransitionWillFinish(_ transition: CFAlertBaseInteractiveTransition) @objc optional func alertViewControllerTransitionDidFinish(_ transition: CFAlertBaseInteractiveTransition) diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..8d4fdca --- /dev/null +++ b/Package.swift @@ -0,0 +1,20 @@ +// swift-tools-version:5.5 + +import PackageDescription + +let package = Package( + name: "CFAlertViewController", + platforms: [.iOS(.v13)], + products: [ + .library( + name: "CFAlertViewController", + targets: ["CFAlertViewController"] + ) + ], + targets: [ + .target( + name: "CFAlertViewController", + path: "CFAlertViewController" + ) + ] +) diff --git a/README.md b/README.md index 609b4bb..14a7ff0 100644 --- a/README.md +++ b/README.md @@ -23,12 +23,24 @@ CFAlertViewController works on devices (iPhone and iPad) with iOS 8.0+. It depen * Foundation.framework * UIKit.framework -#### Install using Cocoapods (recommended) +## Installation + +#### Cocoapods (recommended) We assume that your Cocoapods is already configured. If you are new to Cocoapods, have a look at the [documentation](https://cocoapods.org/) 1. Add `pod 'CFAlertViewController'` to your Podfile. 2. Install the pod(s) by running `pod install` in terminal (in folder where `Podfile` file is located). +#### Swift Package Manager +CFAlertViewController is available through [Swift Package Manager](https://www.swift.org/package-manager/). To install +it using SPM, simply add the following line to your `Package.swift` file: + +``` swift + dependencies: [ + .package(name: "CFAlertViewController", url: "https://github.com/Codigami/CFAlertViewController.git", branch: "master"), + ] +``` + #### Install using Source file Open the downloaded project in Xcode, then drag and drop folder named **CFAlertViewController** onto your project (use the "Product Navigator view"). Make sure to select Copy items when asked if you extracted the code archive outside of your project.