From fc8e79df107ac1ff060959502ac228f37670e3b1 Mon Sep 17 00:00:00 2001 From: Marius Landwehr Date: Sun, 11 Dec 2016 12:50:37 +0100 Subject: [PATCH 01/15] Removed self. acces to be more swiftier --- TinyConsole/TinyConsole.swift | 2 +- TinyConsole/TinyConsoleController.swift | 79 ++++++++++----------- TinyConsole/TinyConsoleViewController.swift | 36 +++++----- 3 files changed, 55 insertions(+), 62 deletions(-) diff --git a/TinyConsole/TinyConsole.swift b/TinyConsole/TinyConsole.swift index d3a7148..9fe88ff 100644 --- a/TinyConsole/TinyConsole.swift +++ b/TinyConsole/TinyConsole.swift @@ -25,7 +25,7 @@ open class TinyConsole { }() func currentTimeStamp() -> String { - return self.dateFormatter.string(from: Date()) + return dateFormatter.string(from: Date()) } public static func scrollToBottom() { diff --git a/TinyConsole/TinyConsoleController.swift b/TinyConsole/TinyConsoleController.swift index e81d27d..7915e17 100644 --- a/TinyConsole/TinyConsoleController.swift +++ b/TinyConsole/TinyConsoleController.swift @@ -22,9 +22,9 @@ open class TinyConsoleController: UIViewController { var consoleWindowMode: TinyConsoleWindowMode = .collapsed { didSet { - self.consoleViewHeightConstraint?.isActive = false - self.consoleViewHeightConstraint?.constant = self.consoleWindowMode == .collapsed ? 0 : 140 - self.consoleViewHeightConstraint?.isActive = true + consoleViewHeightConstraint?.isActive = false + consoleViewHeightConstraint?.constant = consoleWindowMode == .collapsed ? 0 : 140 + consoleViewHeightConstraint?.isActive = true } } @@ -40,22 +40,22 @@ open class TinyConsoleController: UIViewController { override open func viewDidLoad() { super.viewDidLoad() - var consoleFrame = self.view.bounds - consoleFrame.size.height = self.view.bounds.height - 120 + var consoleFrame = view.bounds + consoleFrame.size.height = view.bounds.height - 120 - self.addChildViewController(self.consoleViewController) - self.consoleViewController.view.frame = consoleFrame - self.view.addSubview(self.consoleViewController.view) - self.consoleViewController.didMove(toParentViewController: self) + addChildViewController(consoleViewController) + consoleViewController.view.frame = consoleFrame + view.addSubview(consoleViewController.view) + consoleViewController.didMove(toParentViewController: self) - if let content = self.rootViewController { - self.addChildViewController(content) - content.view.frame = CGRect(x: consoleFrame.minX, y: consoleFrame.maxY, width: self.view.bounds.width, height: 120) - self.view.addSubview(content.view) + if let content = rootViewController { + addChildViewController(content) + content.view.frame = CGRect(x: consoleFrame.minX, y: consoleFrame.maxY, width: view.bounds.width, height: 120) + view.addSubview(content.view) content.didMove(toParentViewController: self) } - self.setupConstraints() + setupConstraints() } lazy var consoleViewHeightConstraint: NSLayoutConstraint? = { @@ -68,50 +68,43 @@ open class TinyConsoleController: UIViewController { func setupConstraints() { if #available(iOS 9, *) { - self.rootViewController?.view.translatesAutoresizingMaskIntoConstraints = false - self.rootViewController?.view.topAnchor.constraint(equalTo: self.view.topAnchor).isActive = true - self.rootViewController?.view.leftAnchor.constraint(equalTo: self.view.leftAnchor).isActive = true - self.rootViewController?.view.rightAnchor.constraint(equalTo: self.view.rightAnchor).isActive = true + let rootViewControllerView = rootViewController?.view + rootViewControllerView?.translatesAutoresizingMaskIntoConstraints = false + rootViewControllerView?.topAnchor.constraint(equalTo: view.topAnchor).isActive = true + rootViewControllerView?.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true + rootViewControllerView?.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true - self.consoleViewController.view.translatesAutoresizingMaskIntoConstraints = false - self.consoleViewController.view.bottomAnchor.constraint(equalTo: self.view.bottomAnchor).isActive = true - self.consoleViewController.view.leftAnchor.constraint(equalTo: self.view.leftAnchor).isActive = true - self.consoleViewController.view.rightAnchor.constraint(equalTo: self.view.rightAnchor).isActive = true + consoleViewController.view.translatesAutoresizingMaskIntoConstraints = false + consoleViewController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true + consoleViewController.view.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true + consoleViewController.view.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true - self.consoleViewHeightConstraint?.isActive = true + consoleViewHeightConstraint?.isActive = true - self.rootViewController?.view.bottomAnchor.constraint(equalTo: self.consoleViewController.view.topAnchor).isActive = true + rootViewController?.view.bottomAnchor.constraint(equalTo: consoleViewController.view.topAnchor).isActive = true } else { - self.rootViewController?.view.translatesAutoresizingMaskIntoConstraints = false - NSLayoutConstraint(item: (self.rootViewController?.view)!, attribute: .top, relatedBy: .equal, toItem: self.view, attribute: .top, multiplier: 1.0, constant: 0).isActive = true - NSLayoutConstraint(item: (self.rootViewController?.view)!, attribute: .left, relatedBy: .equal, toItem: self.view, attribute: .left, multiplier: 1.0, constant: 0).isActive = true - NSLayoutConstraint(item: (self.rootViewController?.view)!, attribute: .right, relatedBy: .equal, toItem: self.view, attribute: .right, multiplier: 1.0, constant: 0).isActive = true + rootViewController?.view.translatesAutoresizingMaskIntoConstraints = false + NSLayoutConstraint(item: (rootViewController?.view)!, attribute: .top, relatedBy: .equal, toItem: view, attribute: .top, multiplier: 1.0, constant: 0).isActive = true + NSLayoutConstraint(item: (rootViewController?.view)!, attribute: .left, relatedBy: .equal, toItem: view, attribute: .left, multiplier: 1.0, constant: 0).isActive = true + NSLayoutConstraint(item: (rootViewController?.view)!, attribute: .right, relatedBy: .equal, toItem: view, attribute: .right, multiplier: 1.0, constant: 0).isActive = true - self.consoleViewController.view.translatesAutoresizingMaskIntoConstraints = false - NSLayoutConstraint(item: self.consoleViewController.view, attribute: .bottom, relatedBy: .equal, toItem: self.view, attribute: .bottom, multiplier: 1.0, constant: 0).isActive = true - NSLayoutConstraint(item: self.consoleViewController.view, attribute: .left, relatedBy: .equal, toItem: self.view, attribute: .left, multiplier: 1.0, constant: 0).isActive = true - NSLayoutConstraint(item: self.consoleViewController.view, attribute: .right, relatedBy: .equal, toItem: self.view, attribute: .right, multiplier: 1.0, constant: 0).isActive = true + consoleViewController.view.translatesAutoresizingMaskIntoConstraints = false + NSLayoutConstraint(item: consoleViewController.view, attribute: .bottom, relatedBy: .equal, toItem: view, attribute: .bottom, multiplier: 1.0, constant: 0).isActive = true + NSLayoutConstraint(item: self.consoleViewController.view, attribute: .left, relatedBy: .equal, toItem: view, attribute: .left, multiplier: 1.0, constant: 0).isActive = true + NSLayoutConstraint(item: self.consoleViewController.view, attribute: .right, relatedBy: .equal, toItem: view, attribute: .right, multiplier: 1.0, constant: 0).isActive = true - self.consoleViewHeightConstraint?.isActive = true + consoleViewHeightConstraint?.isActive = true - NSLayoutConstraint(item: (self.rootViewController?.view)!, attribute: .bottom, relatedBy: .equal, toItem: self.consoleViewController.view, attribute: .top, multiplier: 1.0, constant: 0).isActive = true + NSLayoutConstraint(item: (rootViewController?.view)!, attribute: .bottom, relatedBy: .equal, toItem: consoleViewController.view, attribute: .top, multiplier: 1.0, constant: 0).isActive = true } } - open override func updateViewConstraints() { - super.updateViewConstraints() - } - open override func motionBegan(_ motion: UIEventSubtype, with event: UIEvent?) { if (motion == UIEventSubtype.motionShake) { - self.consoleWindowMode = self.consoleWindowMode == .collapsed ? .expanded : .collapsed + consoleWindowMode = consoleWindowMode == .collapsed ? .expanded : .collapsed UIView.animate(withDuration: 0.25) { self.view.layoutIfNeeded() } } } - - open override func motionEnded(_ motion: UIEventSubtype, with event: UIEvent?) { - - } } diff --git a/TinyConsole/TinyConsoleViewController.swift b/TinyConsole/TinyConsoleViewController.swift index eafb85d..4556e0d 100644 --- a/TinyConsole/TinyConsoleViewController.swift +++ b/TinyConsole/TinyConsoleViewController.swift @@ -19,39 +19,39 @@ class TinyConsoleViewController: UIViewController { override open func viewDidLoad() { super.viewDidLoad() - TinyConsole.shared.textView = self.consoleTextView - self.view.addSubview(self.consoleTextView) + TinyConsole.shared.textView = consoleTextView + view.addSubview(consoleTextView) let addMarkerGesture = UISwipeGestureRecognizer(target: self, action: #selector(addMarker)) - self.view.addGestureRecognizer(addMarkerGesture) + view.addGestureRecognizer(addMarkerGesture) let addCustomTextGesture = UITapGestureRecognizer(target: self, action: #selector(customText)) addCustomTextGesture.numberOfTouchesRequired = 2 if #available(iOS 9, *) { - self.view.addGestureRecognizer(addCustomTextGesture) + view.addGestureRecognizer(addCustomTextGesture) } else { - self.consoleTextView.addGestureRecognizer(addCustomTextGesture) + consoleTextView.addGestureRecognizer(addCustomTextGesture) } let showAdditionalActionsGesture = UITapGestureRecognizer(target: self, action: #selector(additionalActions)) showAdditionalActionsGesture.numberOfTouchesRequired = 3 - self.view.addGestureRecognizer(showAdditionalActionsGesture) + view.addGestureRecognizer(showAdditionalActionsGesture) - self.setupConstraints() + setupConstraints() } func setupConstraints() { - self.consoleTextView.translatesAutoresizingMaskIntoConstraints = false + consoleTextView.translatesAutoresizingMaskIntoConstraints = false if #available(iOS 9, *) { - self.consoleTextView.topAnchor.constraint(equalTo: self.view.topAnchor).isActive = true - self.consoleTextView.leftAnchor.constraint(equalTo: self.view.leftAnchor).isActive = true - self.consoleTextView.rightAnchor.constraint(equalTo: self.view.rightAnchor).isActive = true - self.consoleTextView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor).isActive = true + consoleTextView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true + consoleTextView.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true + consoleTextView.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true + consoleTextView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true } else { - NSLayoutConstraint(item: self.consoleTextView, attribute: .top, relatedBy: .equal, toItem: self.view, attribute: .top, multiplier: 1.0, constant: 0).isActive = true - NSLayoutConstraint(item: self.consoleTextView, attribute: .left, relatedBy: .equal, toItem: self.view, attribute: .left, multiplier: 1.0, constant: 0).isActive = true - NSLayoutConstraint(item: self.consoleTextView, attribute: .right, relatedBy: .equal, toItem: self.view, attribute: .right, multiplier: 1.0, constant: 0).isActive = true - NSLayoutConstraint(item: self.consoleTextView, attribute: .bottom, relatedBy: .equal, toItem: self.view, attribute: .bottom, multiplier: 1.0, constant: 0).isActive = true + NSLayoutConstraint(item: consoleTextView, attribute: .top, relatedBy: .equal, toItem: view, attribute: .top, multiplier: 1.0, constant: 0).isActive = true + NSLayoutConstraint(item: consoleTextView, attribute: .left, relatedBy: .equal, toItem: view, attribute: .left, multiplier: 1.0, constant: 0).isActive = true + NSLayoutConstraint(item: consoleTextView, attribute: .right, relatedBy: .equal, toItem: view, attribute: .right, multiplier: 1.0, constant: 0).isActive = true + NSLayoutConstraint(item: consoleTextView, attribute: .bottom, relatedBy: .equal, toItem: view, attribute: .bottom, multiplier: 1.0, constant: 0).isActive = true } } @@ -73,7 +73,7 @@ class TinyConsoleViewController: UIViewController { alert.addAction(okAction) alert.addAction(cancelAction) - self.present(alert, animated: true, completion: nil) + present(alert, animated: true, completion: nil) } func additionalActions(sender: UITapGestureRecognizer) { @@ -103,7 +103,7 @@ class TinyConsoleViewController: UIViewController { alert.addAction(clearAction) alert.addAction(cancelAction) - self.present(alert, animated: true, completion: nil) + present(alert, animated: true, completion: nil) } func addMarker(sender: UISwipeGestureRecognizer) { From 5e24135f5183b0280cd32514b383eb96bf565d4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Devran=20=C3=9Cnal?= Date: Sun, 11 Dec 2016 13:13:48 +0100 Subject: [PATCH 02/15] Bump version --- TinyConsole.podspec | 2 +- TinyConsole/Supporting Files/Info.plist | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/TinyConsole.podspec b/TinyConsole.podspec index 34bcb2d..bec9b07 100644 --- a/TinyConsole.podspec +++ b/TinyConsole.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TinyConsole' - s.version = '1.2.1' + s.version = '1.3.0' s.summary = 'A tiny log console to display information while using your iOS app. Written in Swift 3.' s.description = <<-DESC diff --git a/TinyConsole/Supporting Files/Info.plist b/TinyConsole/Supporting Files/Info.plist index fbe1e6b..18065b5 100644 --- a/TinyConsole/Supporting Files/Info.plist +++ b/TinyConsole/Supporting Files/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0 + 1.3.0 CFBundleVersion $(CURRENT_PROJECT_VERSION) NSPrincipalClass From abe8f6708f30cafa82c50515d60cd94b973950aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Devran=20=C3=9Cnal?= Date: Sun, 11 Dec 2016 13:14:09 +0100 Subject: [PATCH 03/15] Update README --- README.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3965e8f..a484bc3 100644 --- a/README.md +++ b/README.md @@ -26,13 +26,16 @@ TinyConsoleController(rootViewController: MyMainViewController()) // TinyConsole prints NSFormattedStrings and Strings TinyConsole.print("hello") -// print messages any color you want +// Print messages any color you want TinyConsole.print("green text", color: UIColor.green) -// prints a red error message +// Prints a red error message TinyConsole.error("something went wrong") +// Print a marker for orientation TinyConsole.addMarker() + +// Clear console TinyConsole.clear() ``` @@ -74,6 +77,12 @@ or checkout the example project included in this repository.  text +## Requirements + +* Xcode 8 +* Swift 3 +* iOS 8 or greater + ## Installation ### [Carthage](https://github.com/Carthage/Carthage) From fc855e2da5f2bcde95854677a743e8fbfd6fa95e Mon Sep 17 00:00:00 2001 From: Marius Landwehr Date: Sun, 11 Dec 2016 13:19:04 +0100 Subject: [PATCH 04/15] Cleared up the TinyConsoleController for easier code reading --- TinyConsole/TinyConsoleController.swift | 116 +++++++++++++++++------- 1 file changed, 81 insertions(+), 35 deletions(-) diff --git a/TinyConsole/TinyConsoleController.swift b/TinyConsole/TinyConsoleController.swift index 7915e17..692a88a 100644 --- a/TinyConsole/TinyConsoleController.swift +++ b/TinyConsole/TinyConsoleController.swift @@ -8,12 +8,19 @@ import UIKit + +/// the kind of window modes that are supported by TinyConsole +/// +/// - collapsed: the console is hidden +/// - expanded: the console is shown enum TinyConsoleWindowMode { case collapsed case expanded } open class TinyConsoleController: UIViewController { + + // MARK: - Public Properties - var rootViewController: UIViewController? var consoleViewController: TinyConsoleViewController = { @@ -23,11 +30,32 @@ open class TinyConsoleController: UIViewController { var consoleWindowMode: TinyConsoleWindowMode = .collapsed { didSet { consoleViewHeightConstraint?.isActive = false - consoleViewHeightConstraint?.constant = consoleWindowMode == .collapsed ? 0 : 140 + consoleViewHeightConstraint?.constant = consoleWindowMode == .collapsed ? 0 : self.expandedHeight consoleViewHeightConstraint?.isActive = true } } + lazy var consoleViewHeightConstraint: NSLayoutConstraint? = { + if #available(iOS 9, *) { + return self.consoleViewController.view.heightAnchor.constraint(equalToConstant: 0) + } else { + return NSLayoutConstraint(item: self.consoleViewController.view, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1.0, constant: 0) + } + }() + + // MARK: - Private Properties - + private let consoleFrameHeight: CGFloat = 120 + private let expandedHeight: CGFloat = 140 + + private lazy var consoleFrame: CGRect = { + + var consoleFrame = self.view.bounds + consoleFrame.size.height -= 120 + + return consoleFrame + }() + + // MARK: - Initializer - public init(rootViewController: UIViewController) { self.rootViewController = rootViewController super.init(nibName: nil, bundle: nil) @@ -37,12 +65,10 @@ open class TinyConsoleController: UIViewController { super.init(coder: aDecoder) } + // MARK: - Public Methods - override open func viewDidLoad() { super.viewDidLoad() - var consoleFrame = view.bounds - consoleFrame.size.height = view.bounds.height - 120 - addChildViewController(consoleViewController) consoleViewController.view.frame = consoleFrame view.addSubview(consoleViewController.view) @@ -58,42 +84,22 @@ open class TinyConsoleController: UIViewController { setupConstraints() } - lazy var consoleViewHeightConstraint: NSLayoutConstraint? = { - if #available(iOS 9, *) { - return self.consoleViewController.view.heightAnchor.constraint(equalToConstant: 0) - } else { - return NSLayoutConstraint(item: self.consoleViewController.view, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1.0, constant: 0) - } - }() - func setupConstraints() { + + guard let rootViewControllerView = rootViewController?.view else { + print("You forgot to setup the rootViewController for TinyConsole") + return + } + + rootViewControllerView.attach(anchor: .Top, to: view) + + consoleViewController.view.attach(anchor: .Bottom, to: view) + consoleViewHeightConstraint?.isActive = true + if #available(iOS 9, *) { - let rootViewControllerView = rootViewController?.view - rootViewControllerView?.translatesAutoresizingMaskIntoConstraints = false - rootViewControllerView?.topAnchor.constraint(equalTo: view.topAnchor).isActive = true - rootViewControllerView?.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true - rootViewControllerView?.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true - - consoleViewController.view.translatesAutoresizingMaskIntoConstraints = false - consoleViewController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true - consoleViewController.view.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true - consoleViewController.view.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true - - consoleViewHeightConstraint?.isActive = true rootViewController?.view.bottomAnchor.constraint(equalTo: consoleViewController.view.topAnchor).isActive = true } else { - rootViewController?.view.translatesAutoresizingMaskIntoConstraints = false - NSLayoutConstraint(item: (rootViewController?.view)!, attribute: .top, relatedBy: .equal, toItem: view, attribute: .top, multiplier: 1.0, constant: 0).isActive = true - NSLayoutConstraint(item: (rootViewController?.view)!, attribute: .left, relatedBy: .equal, toItem: view, attribute: .left, multiplier: 1.0, constant: 0).isActive = true - NSLayoutConstraint(item: (rootViewController?.view)!, attribute: .right, relatedBy: .equal, toItem: view, attribute: .right, multiplier: 1.0, constant: 0).isActive = true - - consoleViewController.view.translatesAutoresizingMaskIntoConstraints = false - NSLayoutConstraint(item: consoleViewController.view, attribute: .bottom, relatedBy: .equal, toItem: view, attribute: .bottom, multiplier: 1.0, constant: 0).isActive = true - NSLayoutConstraint(item: self.consoleViewController.view, attribute: .left, relatedBy: .equal, toItem: view, attribute: .left, multiplier: 1.0, constant: 0).isActive = true - NSLayoutConstraint(item: self.consoleViewController.view, attribute: .right, relatedBy: .equal, toItem: view, attribute: .right, multiplier: 1.0, constant: 0).isActive = true - - consoleViewHeightConstraint?.isActive = true NSLayoutConstraint(item: (rootViewController?.view)!, attribute: .bottom, relatedBy: .equal, toItem: consoleViewController.view, attribute: .top, multiplier: 1.0, constant: 0).isActive = true } @@ -108,3 +114,43 @@ open class TinyConsoleController: UIViewController { } } } + +fileprivate extension UIView { + + enum Anchor { + case Top + case Bottom + } + + func attach(anchor: Anchor, to view: UIView) { + + translatesAutoresizingMaskIntoConstraints = false + + if #available(iOS 9, *) { + + switch anchor { + case .Top: + topAnchor.constraint(equalTo: view.topAnchor).isActive = true + case .Bottom: + bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true + } + + leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true + rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true + + } else { + + switch anchor { + case .Top: + NSLayoutConstraint(item: self, attribute: .top, relatedBy: .equal, toItem: view, attribute: .top, multiplier: 1.0, constant: 0).isActive = true + case .Bottom: + NSLayoutConstraint(item: self, attribute: .bottom, relatedBy: .equal, toItem: view, attribute: .bottom, multiplier: 1.0, constant: 0).isActive = true + } + + // left anchor + NSLayoutConstraint(item: self, attribute: .left, relatedBy: .equal, toItem: view, attribute: .left, multiplier: 1.0, constant: 0).isActive = true + // right anchor + NSLayoutConstraint(item: self, attribute: .right, relatedBy: .equal, toItem: view, attribute: .right, multiplier: 1.0, constant: 0).isActive = true + } + } +} From 0c181bfa65e0ff8ea6569c75f0a8f53cb294d08e Mon Sep 17 00:00:00 2001 From: Marius Landwehr Date: Sun, 11 Dec 2016 13:19:41 +0100 Subject: [PATCH 05/15] Swift 3 Enum Style --- TinyConsole/TinyConsoleController.swift | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/TinyConsole/TinyConsoleController.swift b/TinyConsole/TinyConsoleController.swift index 692a88a..b137bcc 100644 --- a/TinyConsole/TinyConsoleController.swift +++ b/TinyConsole/TinyConsoleController.swift @@ -91,9 +91,9 @@ open class TinyConsoleController: UIViewController { return } - rootViewControllerView.attach(anchor: .Top, to: view) + rootViewControllerView.attach(anchor: .top, to: view) - consoleViewController.view.attach(anchor: .Bottom, to: view) + consoleViewController.view.attach(anchor: .bottom, to: view) consoleViewHeightConstraint?.isActive = true if #available(iOS 9, *) { @@ -118,8 +118,8 @@ open class TinyConsoleController: UIViewController { fileprivate extension UIView { enum Anchor { - case Top - case Bottom + case top + case bottom } func attach(anchor: Anchor, to view: UIView) { @@ -129,9 +129,9 @@ fileprivate extension UIView { if #available(iOS 9, *) { switch anchor { - case .Top: + case .top: topAnchor.constraint(equalTo: view.topAnchor).isActive = true - case .Bottom: + case .bottom: bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true } @@ -141,9 +141,9 @@ fileprivate extension UIView { } else { switch anchor { - case .Top: + case .top: NSLayoutConstraint(item: self, attribute: .top, relatedBy: .equal, toItem: view, attribute: .top, multiplier: 1.0, constant: 0).isActive = true - case .Bottom: + case .bottom: NSLayoutConstraint(item: self, attribute: .bottom, relatedBy: .equal, toItem: view, attribute: .bottom, multiplier: 1.0, constant: 0).isActive = true } From 569c32d2ad0996107534d0ef8dcbfaab14ee259e Mon Sep 17 00:00:00 2001 From: Marius Landwehr Date: Sun, 11 Dec 2016 13:31:52 +0100 Subject: [PATCH 06/15] removed the usage of magic numbers --- TinyConsole/TinyConsoleController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TinyConsole/TinyConsoleController.swift b/TinyConsole/TinyConsoleController.swift index b137bcc..1a51af9 100644 --- a/TinyConsole/TinyConsoleController.swift +++ b/TinyConsole/TinyConsoleController.swift @@ -50,7 +50,7 @@ open class TinyConsoleController: UIViewController { private lazy var consoleFrame: CGRect = { var consoleFrame = self.view.bounds - consoleFrame.size.height -= 120 + consoleFrame.size.height -= self.consoleFrameHeight return consoleFrame }() From 22ccfd4cccff903f7981c522f9f9f7abbe1cbe04 Mon Sep 17 00:00:00 2001 From: Marius Landwehr Date: Sun, 11 Dec 2016 13:40:04 +0100 Subject: [PATCH 07/15] Added better Access Control --- TinyConsole/TinyConsoleController.swift | 129 +++++++++++++++--------- 1 file changed, 79 insertions(+), 50 deletions(-) diff --git a/TinyConsole/TinyConsoleController.swift b/TinyConsole/TinyConsoleController.swift index 1a51af9..2b8fa5e 100644 --- a/TinyConsole/TinyConsoleController.swift +++ b/TinyConsole/TinyConsoleController.swift @@ -8,34 +8,25 @@ import UIKit - -/// the kind of window modes that are supported by TinyConsole -/// -/// - collapsed: the console is hidden -/// - expanded: the console is shown -enum TinyConsoleWindowMode { - case collapsed - case expanded -} - open class TinyConsoleController: UIViewController { - // MARK: - Public Properties - - var rootViewController: UIViewController? + /// the kind of window modes that are supported by TinyConsole + /// + /// - collapsed: the console is hidden + /// - expanded: the console is shown + enum WindowMode { + case collapsed + case expanded + } + + // MARK: - Private Properties - + private var rootViewController: UIViewController - var consoleViewController: TinyConsoleViewController = { + private var consoleViewController: TinyConsoleViewController = { return TinyConsoleViewController() }() - var consoleWindowMode: TinyConsoleWindowMode = .collapsed { - didSet { - consoleViewHeightConstraint?.isActive = false - consoleViewHeightConstraint?.constant = consoleWindowMode == .collapsed ? 0 : self.expandedHeight - consoleViewHeightConstraint?.isActive = true - } - } - - lazy var consoleViewHeightConstraint: NSLayoutConstraint? = { + private lazy var consoleViewHeightConstraint: NSLayoutConstraint? = { if #available(iOS 9, *) { return self.consoleViewController.view.heightAnchor.constraint(equalToConstant: 0) } else { @@ -43,7 +34,6 @@ open class TinyConsoleController: UIViewController { } }() - // MARK: - Private Properties - private let consoleFrameHeight: CGFloat = 120 private let expandedHeight: CGFloat = 140 @@ -55,6 +45,14 @@ open class TinyConsoleController: UIViewController { return consoleFrame }() + private var consoleWindowMode: WindowMode = .collapsed { + didSet { + consoleViewHeightConstraint?.isActive = false + consoleViewHeightConstraint?.constant = consoleWindowMode == .collapsed ? 0 : self.expandedHeight + consoleViewHeightConstraint?.isActive = true + } + } + // MARK: - Initializer - public init(rootViewController: UIViewController) { self.rootViewController = rootViewController @@ -62,6 +60,8 @@ open class TinyConsoleController: UIViewController { } required public init?(coder aDecoder: NSCoder) { + assertionFailure("Interface Builder is not supported") + self.rootViewController = UIViewController() super.init(coder: aDecoder) } @@ -74,43 +74,44 @@ open class TinyConsoleController: UIViewController { view.addSubview(consoleViewController.view) consoleViewController.didMove(toParentViewController: self) - if let content = rootViewController { - addChildViewController(content) - content.view.frame = CGRect(x: consoleFrame.minX, y: consoleFrame.maxY, width: view.bounds.width, height: 120) - view.addSubview(content.view) - content.didMove(toParentViewController: self) - } + addChildViewController(rootViewController) + rootViewController.view.frame = CGRect(x: consoleFrame.minX, y: consoleFrame.maxY, width: view.bounds.width, height: 120) + view.addSubview(rootViewController.view) + rootViewController.didMove(toParentViewController: self) setupConstraints() } - func setupConstraints() { - - guard let rootViewControllerView = rootViewController?.view else { - print("You forgot to setup the rootViewController for TinyConsole") - return + open override func motionBegan(_ motion: UIEventSubtype, with event: UIEvent?) { + if (motion == UIEventSubtype.motionShake) { + consoleWindowMode = consoleWindowMode == .collapsed ? .expanded : .collapsed + UIView.animate(withDuration: 0.25) { + self.view.layoutIfNeeded() + } } + } + + // MARK: - Private Methods - + private func setupConstraints() { - rootViewControllerView.attach(anchor: .top, to: view) + rootViewController.view.attach(anchor: .top, to: view) consoleViewController.view.attach(anchor: .bottom, to: view) consoleViewHeightConstraint?.isActive = true if #available(iOS 9, *) { - rootViewController?.view.bottomAnchor.constraint(equalTo: consoleViewController.view.topAnchor).isActive = true + rootViewController.view.bottomAnchor.constraint(equalTo: consoleViewController.view.topAnchor).isActive = true } else { - NSLayoutConstraint(item: (rootViewController?.view)!, attribute: .bottom, relatedBy: .equal, toItem: consoleViewController.view, attribute: .top, multiplier: 1.0, constant: 0).isActive = true - } - } - - open override func motionBegan(_ motion: UIEventSubtype, with event: UIEvent?) { - if (motion == UIEventSubtype.motionShake) { - consoleWindowMode = consoleWindowMode == .collapsed ? .expanded : .collapsed - UIView.animate(withDuration: 0.25) { - self.view.layoutIfNeeded() - } + NSLayoutConstraint(item: (rootViewController.view)!, + attribute: .bottom, + relatedBy: .equal, + toItem: consoleViewController.view, + attribute: .top, + multiplier: 1.0, + constant: 0) + .isActive = true } } } @@ -142,15 +143,43 @@ fileprivate extension UIView { switch anchor { case .top: - NSLayoutConstraint(item: self, attribute: .top, relatedBy: .equal, toItem: view, attribute: .top, multiplier: 1.0, constant: 0).isActive = true + NSLayoutConstraint(item: self, + attribute: .top, + relatedBy: .equal, + toItem: view, + attribute: .top, + multiplier: 1.0, + constant: 0) + .isActive = true case .bottom: - NSLayoutConstraint(item: self, attribute: .bottom, relatedBy: .equal, toItem: view, attribute: .bottom, multiplier: 1.0, constant: 0).isActive = true + NSLayoutConstraint(item: self, + attribute: .bottom, + relatedBy: .equal, + toItem: view, + attribute: .bottom, + multiplier: 1.0, + constant: 0) + .isActive = true } // left anchor - NSLayoutConstraint(item: self, attribute: .left, relatedBy: .equal, toItem: view, attribute: .left, multiplier: 1.0, constant: 0).isActive = true + NSLayoutConstraint(item: self, + attribute: .left, + relatedBy: .equal, + toItem: view, + attribute: .left, + multiplier: 1.0, + constant: 0) + .isActive = true // right anchor - NSLayoutConstraint(item: self, attribute: .right, relatedBy: .equal, toItem: view, attribute: .right, multiplier: 1.0, constant: 0).isActive = true + NSLayoutConstraint(item: self, + attribute: .right, + relatedBy: .equal, + toItem: view, + attribute: .right, + multiplier: 1.0, + constant: 0) + .isActive = true } } } From 2fe5fbe971400e6f621f86b6fc79eee85d0fea48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Devran=20=C3=9Cnal?= Date: Sun, 11 Dec 2016 13:50:34 +0100 Subject: [PATCH 08/15] Cosmetic changes --- TinyConsole/TinyConsole.swift | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/TinyConsole/TinyConsole.swift b/TinyConsole/TinyConsole.swift index 9fe88ff..00e8142 100644 --- a/TinyConsole/TinyConsole.swift +++ b/TinyConsole/TinyConsole.swift @@ -12,7 +12,9 @@ open class TinyConsole { public static var shared = TinyConsole() var textView: UITextView? - public static var textAppearance = [NSFontAttributeName : UIFont(name: "Menlo", size: 12.0)!, NSForegroundColorAttributeName : UIColor.white] + public static var textAppearance = [ + NSFontAttributeName: UIFont(name: "Menlo", size: 12.0)!, + NSForegroundColorAttributeName: UIColor.white] private init() { } @@ -36,7 +38,7 @@ open class TinyConsole { } } - public static func print(_ text: String, global: Bool = true, color : UIColor = UIColor.white) { + public static func print(_ text: String, global: Bool = true, color: UIColor = UIColor.white) { let formattedText = NSMutableAttributedString(string: text) let range = NSRange(location: 0, length: formattedText.length) @@ -47,7 +49,7 @@ open class TinyConsole { TinyConsole.print(formattedText, global: global) } - public static func print(_ text: NSAttributedString, global : Bool = true) { + public static func print(_ text: NSAttributedString, global: Bool = true) { if let textView = shared.textView { let timeStamped = NSMutableAttributedString(string: shared.currentTimeStamp() + " ") let range = NSRange(location: 0, length: timeStamped.length) From 967f77fb68368a7de7b61ff5af6346b40570f05b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Devran=20=C3=9Cnal?= Date: Sun, 11 Dec 2016 13:51:18 +0100 Subject: [PATCH 09/15] Modify UITextView in main thread --- TinyConsole/TinyConsole.swift | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/TinyConsole/TinyConsole.swift b/TinyConsole/TinyConsole.swift index 00e8142..9aaf21f 100644 --- a/TinyConsole/TinyConsole.swift +++ b/TinyConsole/TinyConsole.swift @@ -51,19 +51,19 @@ open class TinyConsole { public static func print(_ text: NSAttributedString, global: Bool = true) { if let textView = shared.textView { - let timeStamped = NSMutableAttributedString(string: shared.currentTimeStamp() + " ") - let range = NSRange(location: 0, length: timeStamped.length) + DispatchQueue.main.async { + let timeStamped = NSMutableAttributedString(string: shared.currentTimeStamp() + " ") + let range = NSRange(location: 0, length: timeStamped.length) - // set standard text appearance for time-stamp - timeStamped.addAttributes(TinyConsole.textAppearance, range: range) - - timeStamped.append(text) - timeStamped.append(NSAttributedString(string :"\n")) + // set standard text appearance for time-stamp + timeStamped.addAttributes(TinyConsole.textAppearance, range: range) - let newText = NSMutableAttributedString(attributedString: textView.attributedText) - newText.append(timeStamped) + timeStamped.append(text) + timeStamped.append(NSAttributedString(string: "\n")) + + let newText = NSMutableAttributedString(attributedString: textView.attributedText) + newText.append(timeStamped) - DispatchQueue.main.async { textView.attributedText = newText TinyConsole.scrollToBottom() } From 380bbc1529c073cb11c06821eb3fb2683f6766ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Devran=20=C3=9Cnal?= Date: Sun, 11 Dec 2016 13:59:32 +0100 Subject: [PATCH 10/15] Reorder parameter signature of print method --- TinyConsole/TinyConsole.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TinyConsole/TinyConsole.swift b/TinyConsole/TinyConsole.swift index 9aaf21f..716a6cb 100644 --- a/TinyConsole/TinyConsole.swift +++ b/TinyConsole/TinyConsole.swift @@ -38,7 +38,7 @@ open class TinyConsole { } } - public static func print(_ text: String, global: Bool = true, color: UIColor = UIColor.white) { + public static func print(_ text: String, color: UIColor = UIColor.white, global: Bool = true) { let formattedText = NSMutableAttributedString(string: text) let range = NSRange(location: 0, length: formattedText.length) From b7274c5a86eae7b1494dd028d5058f3c47d0f4dc Mon Sep 17 00:00:00 2001 From: Marius Landwehr Date: Sun, 11 Dec 2016 14:11:19 +0100 Subject: [PATCH 11/15] Updated Readme.md for swiftier setup --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index a484bc3..2141ee6 100644 --- a/README.md +++ b/README.md @@ -53,9 +53,9 @@ Instead of ```swift func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { - self.window = UIWindow(frame: UIScreen.main.bounds) - self.window?.rootViewController = MainViewController() - self.window?.makeKeyAndVisible() + window = UIWindow(frame: UIScreen.main.bounds) + window?.rootViewController = MainViewController() + window?.makeKeyAndVisible() return true } ``` @@ -64,9 +64,9 @@ write ```swift func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { - self.window = UIWindow(frame: UIScreen.main.bounds) - self.window?.rootViewController = TinyConsoleController(rootViewController: MainViewController()) - self.window?.makeKeyAndVisible() + window = UIWindow(frame: UIScreen.main.bounds) + window?.rootViewController = TinyConsoleController(rootViewController: MainViewController()) + window?.makeKeyAndVisible() return true } ``` From 82b9be2c9c94efcb16f075321a8975c2de49eb15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Devran=20=C3=9Cnal?= Date: Sun, 11 Dec 2016 14:18:29 +0100 Subject: [PATCH 12/15] Clean up example target --- TinyConsole-Example/AppDelegate.swift | 6 +-- TinyConsole-Example/DataSource.swift | 29 ++++++++++ TinyConsole-Example/Delegate.swift | 16 ++++++ TinyConsole-Example/MainViewController.swift | 57 +++++++++++--------- TinyConsole.xcodeproj/project.pbxproj | 8 +++ 5 files changed, 88 insertions(+), 28 deletions(-) create mode 100644 TinyConsole-Example/DataSource.swift create mode 100644 TinyConsole-Example/Delegate.swift diff --git a/TinyConsole-Example/AppDelegate.swift b/TinyConsole-Example/AppDelegate.swift index 7d4037f..45730c2 100644 --- a/TinyConsole-Example/AppDelegate.swift +++ b/TinyConsole-Example/AppDelegate.swift @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { - self.window = UIWindow(frame: UIScreen.main.bounds) + window = UIWindow(frame: UIScreen.main.bounds) let viewController = UINavigationController(rootViewController: MainViewController()) viewController.title = "Main" @@ -25,8 +25,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate { viewController ] - self.window?.rootViewController = TinyConsoleController(rootViewController: tabBarController) - self.window?.makeKeyAndVisible() + window?.rootViewController = TinyConsoleController(rootViewController: tabBarController) + window?.makeKeyAndVisible() return true } diff --git a/TinyConsole-Example/DataSource.swift b/TinyConsole-Example/DataSource.swift new file mode 100644 index 0000000..84c46bf --- /dev/null +++ b/TinyConsole-Example/DataSource.swift @@ -0,0 +1,29 @@ +// +// DataSource.swift +// TinyConsole +// +// Created by Devran Uenal on 11.12.16. +// +// + +import UIKit + +class MainTableViewDataSource: NSObject, UITableViewDataSource { + func registerCellsForTableView(_ tableView: UITableView) { + tableView.register(UITableViewCell.self, forCellReuseIdentifier: "default") + } + + func numberOfSections(in tableView: UITableView) -> Int { + return 1 + } + + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return 30 + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCell(withIdentifier: "default", for: indexPath) + cell.textLabel?.text = "Row \(indexPath.row)" + return cell + } +} diff --git a/TinyConsole-Example/Delegate.swift b/TinyConsole-Example/Delegate.swift new file mode 100644 index 0000000..e3a5510 --- /dev/null +++ b/TinyConsole-Example/Delegate.swift @@ -0,0 +1,16 @@ +// +// Delegate.swift +// TinyConsole +// +// Created by Devran Uenal on 11.12.16. +// +// + +import UIKit +import TinyConsole + +class MainTableViewDelegate: NSObject, UITableViewDelegate { + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + TinyConsole.print("Tapped on \(indexPath.row)") + } +} diff --git a/TinyConsole-Example/MainViewController.swift b/TinyConsole-Example/MainViewController.swift index 8c68910..c629a45 100644 --- a/TinyConsole-Example/MainViewController.swift +++ b/TinyConsole-Example/MainViewController.swift @@ -10,41 +10,49 @@ import UIKit import TinyConsole class MainViewController: UITableViewController { - override func viewDidLoad() { - super.viewDidLoad() - self.view.backgroundColor = UIColor.white - - self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: "default") - - self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Add Log", style: UIBarButtonItemStyle.plain, target: self, action: #selector(addLog)) - self.navigationItem.rightBarButtonItems = [ - UIBarButtonItem(title: "Add Marker", style: UIBarButtonItemStyle.plain, target: self, action: #selector(addMarker)), - UIBarButtonItem(title: "Clear", style: UIBarButtonItemStyle.plain, target: self, action: #selector(clear)), - ] - } + var tableViewDelegate: UITableViewDelegate + var tableViewDataSource: UITableViewDataSource - override func numberOfSections(in tableView: UITableView) -> Int { - return 1 + init() { + tableViewDelegate = MainTableViewDelegate() + tableViewDataSource = MainTableViewDataSource() + super.init(style: UITableViewStyle.plain) } - override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return 30 + required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") } - override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell = self.tableView.dequeueReusableCell(withIdentifier: "default", for: indexPath) + override func viewDidLoad() { + (tableViewDataSource as? MainTableViewDataSource)?.registerCellsForTableView(self.tableView) + tableView.delegate = tableViewDelegate + tableView.dataSource = tableViewDataSource - cell.textLabel?.text = "Row \(indexPath.row)" + super.viewDidLoad() + view.backgroundColor = UIColor.white - return cell + setupNavigationItems() } - - override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - TinyConsole.print("Tapped on \(indexPath.row)") + + override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + } + func setupNavigationItems() { + navigationItem.leftBarButtonItems = [ + UIBarButtonItem(title: "Add Log", style: UIBarButtonItemStyle.plain, target: self, action: #selector(addLog)) + ] + navigationItem.rightBarButtonItems = [ + UIBarButtonItem( title: "Add Marker", style: UIBarButtonItemStyle.plain, target: self, action: #selector(addMarker)), + UIBarButtonItem( title: "Clear", style: UIBarButtonItemStyle.plain, target: self, action: #selector(clear)), + ] + } +} + +extension MainViewController { func addLog() { - TinyConsole.print("hello world") + TinyConsole.print("Hello World") } func clear() { @@ -55,4 +63,3 @@ class MainViewController: UITableViewController { TinyConsole.addMarker() } } - diff --git a/TinyConsole.xcodeproj/project.pbxproj b/TinyConsole.xcodeproj/project.pbxproj index 2c67ddf..58c664b 100644 --- a/TinyConsole.xcodeproj/project.pbxproj +++ b/TinyConsole.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 450284DE1DFD878C00922381 /* DataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 450284DD1DFD878C00922381 /* DataSource.swift */; }; + 450284E01DFD87BA00922381 /* Delegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 450284DF1DFD87BA00922381 /* Delegate.swift */; }; 457B894F1DF4DB74001DD49C /* TinyConsole.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4585FDCB1DEC54B800DDF5EB /* TinyConsole.framework */; }; 457B89501DF4DB74001DD49C /* TinyConsole.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 4585FDCB1DEC54B800DDF5EB /* TinyConsole.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 4585FDD81DEC54D300DDF5EB /* TinyConsole.h in Headers */ = {isa = PBXBuildFile; fileRef = 4585FDD61DEC54D300DDF5EB /* TinyConsole.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -44,6 +46,8 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 450284DD1DFD878C00922381 /* DataSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DataSource.swift; sourceTree = ""; }; + 450284DF1DFD87BA00922381 /* Delegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Delegate.swift; sourceTree = ""; }; 4585FDCB1DEC54B800DDF5EB /* TinyConsole.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = TinyConsole.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 4585FDD51DEC54D300DDF5EB /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 4585FDD61DEC54D300DDF5EB /* TinyConsole.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TinyConsole.h; sourceTree = ""; }; @@ -120,6 +124,8 @@ children = ( 4585FDE51DEC58BB00DDF5EB /* AppDelegate.swift */, 4585FDE71DEC58BB00DDF5EB /* MainViewController.swift */, + 450284DD1DFD878C00922381 /* DataSource.swift */, + 450284DF1DFD87BA00922381 /* Delegate.swift */, 4585FDEC1DEC58BB00DDF5EB /* Assets.xcassets */, 4585FDEE1DEC58BB00DDF5EB /* LaunchScreen.storyboard */, 4585FDF11DEC58BB00DDF5EB /* Info.plist */, @@ -251,6 +257,8 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 450284E01DFD87BA00922381 /* Delegate.swift in Sources */, + 450284DE1DFD878C00922381 /* DataSource.swift in Sources */, 4585FDE81DEC58BB00DDF5EB /* MainViewController.swift in Sources */, 4585FDE61DEC58BB00DDF5EB /* AppDelegate.swift in Sources */, ); From 4798c168eb47672c9c99703a28090da8127b7059 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Devran=20=C3=9Cnal?= Date: Sun, 11 Dec 2016 14:19:00 +0100 Subject: [PATCH 13/15] Show messages in example target --- TinyConsole-Example/MainViewController.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/TinyConsole-Example/MainViewController.swift b/TinyConsole-Example/MainViewController.swift index c629a45..f1c4333 100644 --- a/TinyConsole-Example/MainViewController.swift +++ b/TinyConsole-Example/MainViewController.swift @@ -37,6 +37,12 @@ class MainViewController: UITableViewController { override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) + TinyConsole.print("Welcome to TinyConsole") + TinyConsole.addMarker() + TinyConsole.print("NOW", color: UIColor.red) + TinyConsole.print("IN", color: UIColor.green) + TinyConsole.print("COLOR", color: UIColor.blue) + TinyConsole.addMarker() } func setupNavigationItems() { From 36dd1baca06b1c87a794655d4dc83527afd75bd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Devran=20=C3=9Cnal?= Date: Sun, 11 Dec 2016 14:22:12 +0100 Subject: [PATCH 14/15] Update README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2141ee6..ce0403e 100644 --- a/README.md +++ b/README.md @@ -23,13 +23,13 @@ TinyConsoleController(rootViewController: MyMainViewController()) ### Actions ```swift -// TinyConsole prints NSFormattedStrings and Strings +// Print message TinyConsole.print("hello") // Print messages any color you want TinyConsole.print("green text", color: UIColor.green) -// Prints a red error message +// Print a red error message TinyConsole.error("something went wrong") // Print a marker for orientation From 4fdba9739ad51aa572d1e5e87b1a56a36820c8d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Devran=20=C3=9Cnal?= Date: Sun, 11 Dec 2016 14:27:08 +0100 Subject: [PATCH 15/15] Bump version --- TinyConsole.podspec | 2 +- TinyConsole/Supporting Files/Info.plist | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/TinyConsole.podspec b/TinyConsole.podspec index bec9b07..a97b42d 100644 --- a/TinyConsole.podspec +++ b/TinyConsole.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'TinyConsole' - s.version = '1.3.0' + s.version = '1.3.1' s.summary = 'A tiny log console to display information while using your iOS app. Written in Swift 3.' s.description = <<-DESC diff --git a/TinyConsole/Supporting Files/Info.plist b/TinyConsole/Supporting Files/Info.plist index 18065b5..9f9016a 100644 --- a/TinyConsole/Supporting Files/Info.plist +++ b/TinyConsole/Supporting Files/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.3.0 + 1.3.1 CFBundleVersion $(CURRENT_PROJECT_VERSION) NSPrincipalClass