Skip to content

Commit

Permalink
Merge pull request #38 from tiagomartinho/master
Browse files Browse the repository at this point in the history
 Migrate to Swift 4.2
  • Loading branch information
Cosmo committed Mar 17, 2019
2 parents 7c655b9 + 27ca52e commit 5537002
Show file tree
Hide file tree
Showing 10 changed files with 247 additions and 191 deletions.
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@

# TinyConsole

<img src="https://img.shields.io/badge/platform-iOS-blue.svg?style=flat" alt="Platform iOS" />
<img src="https://img.shields.io/badge/swift3-compatible-green.svg?style=flat" alt="Swift 3 compatible" />
<img src="https://img.shields.io/badge/Carthage-compatible-brightgreen.svg?style=flat" alt="Carthage compatible" />
<img src="https://img.shields.io/badge/license-MIT-blue.svg?style=flat" alt="License MIT" />
<img src="https://img.shields.io/badge/platform-iOS-blue.svg?style=flat" alt="Platform iOS" /> <img src="https://img.shields.io/badge/swift4.2-compatible-green.svg?style=flat" alt="Swift 4.2 compatible" /> <img src="https://img.shields.io/badge/Cocoapods-compatible-brightgreen.svg?style=flat" alt="Cocoapods compatible" /> <img src="https://img.shields.io/badge/Carthage-compatible-brightgreen.svg?style=flat" alt="Carthage compatible" /> <img src="https://img.shields.io/badge/license-MIT-blue.svg?style=flat" alt="License MIT" />

A tiny log console to display information while using your iOS app.
Written in Swift 3.
Written in Swift 4.2.

## Usage

Expand Down Expand Up @@ -98,8 +95,8 @@ or checkout the example project included in this repository.

## Requirements

* Xcode 8
* Swift 3
* Xcode 10
* Swift 4.2
* iOS 8 or greater

## Installation
Expand Down
51 changes: 23 additions & 28 deletions TinyConsole-Example/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,31 @@
//
//

import UIKit
import TinyConsole
import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)

let viewController = UINavigationController(rootViewController: MainViewController())
viewController.title = "Main"
viewController.tabBarItem = UITabBarItem(tabBarSystemItem: UITabBarSystemItem.recents, tag: 0)
viewController.tabBarItem = UITabBarItem(tabBarSystemItem: .recents, tag: 0)

let tabBarController = UITabBarController()
tabBarController.viewControllers = [
viewController
]

// deprecated
// window?.rootViewController = TinyConsoleController(rootViewController: tabBarController)




// TinyConsole with default gesture recognizers
// window?.rootViewController = TinyConsole.createViewController(rootViewController: tabBarController)

// TinyConsole with custom gesture reconizers
window?.rootViewController = TinyConsole.createViewController(rootViewController: tabBarController, withDefaultGestureConfiguration: false)
// single tap
Expand All @@ -47,52 +45,49 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// swipe
let swipeGestureRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(consoleSwiped))
TinyConsole.addGestureRecognizer(swipeGestureRecognizer)

// Calling this func to set back to default configuration
// TinyConsole.useDefaultGestureConfiguration()

window?.makeKeyAndVisible()

return true
}
func consoleTapped(sender: UITapGestureRecognizer) {

@objc func consoleTapped(sender _: UITapGestureRecognizer) {
TinyConsole.print("console tapped, do nothing", global: true)
}
func consoleDoubleTapped(sender: UITapGestureRecognizer) {

@objc func consoleDoubleTapped(sender _: UITapGestureRecognizer) {
TinyConsole.print("console double tapped, do nothing", global: true)
}
func consoleSwiped(sender: UISwipeGestureRecognizer) {

@objc func consoleSwiped(sender _: UISwipeGestureRecognizer) {
TinyConsole.print("console swipped, change to red view controller", global: true)
let vc = UIViewController()
vc.view.backgroundColor = UIColor.red
TinyConsole.set(rootViewController: vc)
}

func applicationWillResignActive(_ application: UIApplication) {
func applicationWillResignActive(_: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}

func applicationDidEnterBackground(_ application: UIApplication) {
func applicationDidEnterBackground(_: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(_ application: UIApplication) {
func applicationWillEnterForeground(_: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(_ application: UIApplication) {
func applicationDidBecomeActive(_: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(_ application: UIApplication) {
func applicationWillTerminate(_: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


}

10 changes: 5 additions & 5 deletions TinyConsole-Example/DataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ class MainTableViewDataSource: NSObject, UITableViewDataSource {
func registerCellsForTableView(_ tableView: UITableView) {
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "default")
}
func numberOfSections(in tableView: UITableView) -> Int {

func numberOfSections(in _: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

func tableView(_: UITableView, numberOfRowsInSection _: 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)"
Expand Down
4 changes: 2 additions & 2 deletions TinyConsole-Example/Delegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
//
//

import UIKit
import TinyConsole
import UIKit

class MainTableViewDelegate: NSObject, UITableViewDelegate {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
func tableView(_: UITableView, didSelectRowAt indexPath: IndexPath) {
TinyConsole.print("Tapped on \(indexPath.row)")
}
}
38 changes: 19 additions & 19 deletions TinyConsole-Example/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,66 +6,66 @@
//
//

import UIKit
import TinyConsole
import UIKit

class MainViewController: UITableViewController {
var tableViewDelegate: UITableViewDelegate
var tableViewDataSource: UITableViewDataSource

init() {
tableViewDelegate = MainTableViewDelegate()
tableViewDataSource = MainTableViewDataSource()
super.init(style: UITableViewStyle.plain)
super.init(style: .plain)
}
required init?(coder aDecoder: NSCoder) {

required init?(coder _: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override func viewDidLoad() {
(tableViewDataSource as? MainTableViewDataSource)?.registerCellsForTableView(self.tableView)
(tableViewDataSource as? MainTableViewDataSource)?.registerCellsForTableView(tableView)
tableView.delegate = tableViewDelegate
tableView.dataSource = tableViewDataSource

super.viewDidLoad()
view.backgroundColor = UIColor.white

setupNavigationItems()
}

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() {
navigationItem.leftBarButtonItems = [
UIBarButtonItem(title: "Add Log", style: UIBarButtonItemStyle.plain, target: self, action: #selector(addLog))
UIBarButtonItem(title: "Add Log", style: .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)),
UIBarButtonItem(title: "Add Marker", style: .plain, target: self, action: #selector(addMarker)),
UIBarButtonItem(title: "Clear", style: .plain, target: self, action: #selector(clear))
]
}
}

extension MainViewController {
func addLog() {
@objc func addLog() {
TinyConsole.print("Hello World")
}
func clear() {

@objc func clear() {
TinyConsole.clear()
}
func addMarker() {

@objc func addMarker() {
TinyConsole.addMarker()
}
}
71 changes: 63 additions & 8 deletions TinyConsole.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,16 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0810;
LastUpgradeCheck = 0810;
LastUpgradeCheck = 1000;
TargetAttributes = {
4585FDCA1DEC54B800DDF5EB = {
CreatedOnToolsVersion = 8.1;
LastSwiftMigration = 0810;
LastSwiftMigration = 1000;
ProvisioningStyle = Automatic;
};
4585FDE21DEC58BB00DDF5EB = {
CreatedOnToolsVersion = 8.1;
LastSwiftMigration = 1000;
ProvisioningStyle = Manual;
};
};
Expand Down Expand Up @@ -289,12 +290,64 @@
4585FDC41DEC532500DDF5EB /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
ONLY_ACTIVE_ARCH = YES;
};
name = Debug;
};
4585FDC51DEC532500DDF5EB /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
};
name = Release;
};
Expand All @@ -320,7 +373,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = dwarf;
Expand Down Expand Up @@ -357,7 +410,7 @@
SKIP_INSTALL = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down Expand Up @@ -386,7 +439,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
Expand Down Expand Up @@ -415,7 +468,7 @@
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand Down Expand Up @@ -476,7 +529,8 @@
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand Down Expand Up @@ -526,7 +580,8 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
Expand Down
Loading

0 comments on commit 5537002

Please sign in to comment.