From a5051b5e1397e5b258bb77d67b7f8a00819eb267 Mon Sep 17 00:00:00 2001 From: Afnan Mirza Date: Sat, 14 May 2022 16:50:32 -0400 Subject: [PATCH] * Adding `Package.swift` to support SPM. * Updating `.gitignore` to ignore `.swiftpm`. * Fixing module issue in `CleanyAlertActionTableViewCell.xib`. * Adding `Bundle+Extension.swift` to hold bundle extensions. * Added `current` bundle variable which returns the current module for either SPM or Cocoapods. * Updating `README.md` --- .gitignore | 1 + .../CleanyAlertActionTableViewCell.xib | 17 ++++++++-------- .../Classes/CleanyAlertViewController.swift | 5 ++--- .../Classes/Helper/Bundle+Extension.swift | 18 +++++++++++++++++ Package.swift | 20 +++++++++++++++++++ README.md | 11 ++++++++++ 6 files changed, 60 insertions(+), 12 deletions(-) create mode 100644 CleanyModal/Classes/Helper/Bundle+Extension.swift create mode 100644 Package.swift diff --git a/.gitignore b/.gitignore index b957ede..8c34938 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ profile DerivedData *.hmap *.ipa +.swiftpm # Bundler .bundle diff --git a/CleanyModal/Classes/CleanyAlertActionTableViewCell.xib b/CleanyModal/Classes/CleanyAlertActionTableViewCell.xib index 81da6c3..5463ae9 100644 --- a/CleanyModal/Classes/CleanyAlertActionTableViewCell.xib +++ b/CleanyModal/Classes/CleanyAlertActionTableViewCell.xib @@ -1,31 +1,30 @@ - - - - + + - + + - + - + - + diff --git a/CleanyModal/Classes/CleanyAlertViewController.swift b/CleanyModal/Classes/CleanyAlertViewController.swift index 3680ccd..1a05495 100644 --- a/CleanyModal/Classes/CleanyAlertViewController.swift +++ b/CleanyModal/Classes/CleanyAlertViewController.swift @@ -76,7 +76,7 @@ open class CleanyAlertViewController: CleanyModalViewController { if let nibName = customNibName { super.init(nibName: nibName, bundle: nil) } else { - super.init(nibName: "CleanyAlertViewController", bundle: Bundle(for: CleanyAlertViewController.self)) + super.init(nibName: "CleanyAlertViewController", bundle: .current) } } @@ -289,9 +289,8 @@ open class CleanyAlertViewController: CleanyModalViewController { actionsTV.dataSource = self actionsTV.delegate = self - let bundle = Bundle(for: CleanyAlertActionTableViewCell.self) actionsTV.register( - UINib(nibName: "CleanyAlertActionTableViewCell", bundle: bundle), + UINib(nibName: "CleanyAlertActionTableViewCell", bundle: .current), forCellReuseIdentifier: kCellReuseIdentifier ) } diff --git a/CleanyModal/Classes/Helper/Bundle+Extension.swift b/CleanyModal/Classes/Helper/Bundle+Extension.swift new file mode 100644 index 0000000..f512017 --- /dev/null +++ b/CleanyModal/Classes/Helper/Bundle+Extension.swift @@ -0,0 +1,18 @@ +// +// Bundle+Extension.swift +// CleanyModal +// +// Created by Afnan Mirza on 5/14/22. +// + +import Foundation + +extension Bundle { + static var current: Bundle? { + #if SWIFT_PACKAGE + return .module + #else + Bundle(for: CleanyAlertViewController.self) + #endif + } +} diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..e0661c9 --- /dev/null +++ b/Package.swift @@ -0,0 +1,20 @@ +// swift-tools-version:5.5 + +import PackageDescription + +let package = Package( + name: "CleanyModal", + platforms: [.iOS(.v13)], + products: [ + .library( + name: "CleanyModal", + targets: ["CleanyModal"] + ) + ], + targets: [ + .target( + name: "CleanyModal", + path: "CleanyModal" + ) + ] +) diff --git a/README.md b/README.md index 707b329..0f41952 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,7 @@ See example project to see all abilities to customize, enjoy ! ## Installation +### Cocoapods CleanyModal is available through [CocoaPods](http://cocoapods.org). To install it, simply add the following line to your Podfile: @@ -91,6 +92,16 @@ it, simply add the following line to your Podfile: pod 'CleanyModal' ``` +### Swift Package Manager +CleanyModal is also 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: "CleanyModal", url: "https://github.com/loryhuz/CleanyModal.git", branch: "master"), + ] +``` + ## Author lory huz, lory.huz@gmail.com