Skip to content

Commit

Permalink
Adds support for SPM
Browse files Browse the repository at this point in the history
  • Loading branch information
Lonnie Gerol committed Mar 1, 2022
1 parent 47f41ee commit 1d00ffc
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 16 deletions.
7 changes: 7 additions & 0 deletions .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions BRYXBanner.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "BRYXBanner"
s.version = "0.8.4"
s.version = "0.8.5"
s.summary = "A lightweight dropdown notification for iOS 8+, in Swift."
s.homepage = "https://github.com/bryx-inc/BRYXBanner"
s.license = 'MIT'
Expand All @@ -12,5 +12,5 @@ Pod::Spec.new do |s|

s.swift_version = '5.0'

s.source_files = 'Pod/Classes/**/*'
s.source_files = 'Sources/BRYXBanner/*.swift'
end
31 changes: 31 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "BRYXBanner",
platforms: [.iOS(.v8)],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "BRYXBanner",
targets: ["BRYXBanner"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "BRYXBanner",
dependencies: [],
path: "Sources"),
.testTarget(
name: "BRYXBannerTests",
dependencies: ["BRYXBanner"],
path: "Tests"),
]
)
Empty file removed Pod/Assets/.gitkeep
Empty file.
Empty file removed Pod/Classes/.gitkeep
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public enum BannerSpringiness {

/// Banner is a dropdown notification view that presents above the main view controller, but below the status bar.
open class Banner: UIView {
@objc class func topWindow() -> UIWindow? {
@objc open class func topWindow() -> UIWindow? {
for window in UIApplication.shared.windows.reversed() {
if window.windowLevel == UIWindow.Level.normal && window.isKeyWindow && window.frame != CGRect.zero { return window }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@
// Created by Anthony Miller on 11/12/15.
//

import Foundation
import UIKit
import BRYXBanner

private let MockBannerShownNotificationName = "MockBannerShownNotification"
private let MockBannerShownNotificationName = NSNotification.Name("MockBannerShownNotification")

/// This mock banner can be used in place of a `Banner` in unit tests in order to verify that it will be displayed.
public class MockBanner: Banner {

/// The view that the banner is shown in. Captured from the `view` parameter in the `show(view: duration:)` method
var viewForBanner: UIView?

override public func show(view: UIView? = MockBanner.topWindow(), duration: NSTimeInterval? = nil) {
viewForBanner = view
NSNotificationCenter.defaultCenter().postNotificationName(MockBannerShownNotificationName, object: self)
override public func show(_ view: UIView? = MockBanner.topWindow(), duration: TimeInterval? = nil) {
viewForBanner = view
NotificationCenter.default.post(name: MockBannerShownNotificationName, object: self)
}

}
Expand All @@ -31,22 +32,23 @@ public class MockBannerVerifier: NSObject {
override init() {
super.init()

NSNotificationCenter.defaultCenter().addObserver(self,
selector: "bannerShown:",
name: MockBannerShownNotificationName,
object: nil)
NotificationCenter.default.addObserver(
self,
selector: #selector(bannerShown(notification:)),
name: MockBannerShownNotificationName,
object: nil
)
}


deinit {
NSNotificationCenter.defaultCenter().removeObserver(self)
NotificationCenter.default.removeObserver(self)
}

func bannerShown(notification: NSNotification) {
@objc func bannerShown(notification: NSNotification) {
if let banner = notification.object as? MockBanner {
bannerShown = banner
}
}

}


0 comments on commit 1d00ffc

Please sign in to comment.