Skip to content

Adding SPM Support #25

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.swiftpm
20 changes: 13 additions & 7 deletions CFAlertViewController/CFAlertViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import UIKit


public protocol CFAlertActionTableViewCellDelegate: class {
public protocol CFAlertActionTableViewCellDelegate: AnyObject {
func alertActionCell(_ cell: CFAlertActionTableViewCell, didClickAction action: CFAlertAction?)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
20 changes: 20 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -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"
)
]
)
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down