Skip to content

Commit 5537002

Browse files
authored
Merge pull request #38 from tiagomartinho/master
Migrate to Swift 4.2
2 parents 7c655b9 + 27ca52e commit 5537002

File tree

10 files changed

+247
-191
lines changed

10 files changed

+247
-191
lines changed

README.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@
22

33
# TinyConsole
44

5-
<img src="https://img.shields.io/badge/platform-iOS-blue.svg?style=flat" alt="Platform iOS" />
6-
<img src="https://img.shields.io/badge/swift3-compatible-green.svg?style=flat" alt="Swift 3 compatible" />
7-
<img src="https://img.shields.io/badge/Carthage-compatible-brightgreen.svg?style=flat" alt="Carthage compatible" />
8-
<img src="https://img.shields.io/badge/license-MIT-blue.svg?style=flat" alt="License MIT" />
5+
<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" />
96

107
A tiny log console to display information while using your iOS app.
11-
Written in Swift 3.
8+
Written in Swift 4.2.
129

1310
## Usage
1411

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

9996
## Requirements
10097

101-
* Xcode 8
102-
* Swift 3
98+
* Xcode 10
99+
* Swift 4.2
103100
* iOS 8 or greater
104101

105102
## Installation

TinyConsole-Example/AppDelegate.swift

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,31 @@
66
//
77
//
88

9-
import UIKit
109
import TinyConsole
10+
import UIKit
1111

1212
@UIApplicationMain
1313
class AppDelegate: UIResponder, UIApplicationDelegate {
1414
var window: UIWindow?
15-
16-
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
15+
16+
func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
1717
window = UIWindow(frame: UIScreen.main.bounds)
18-
18+
1919
let viewController = UINavigationController(rootViewController: MainViewController())
2020
viewController.title = "Main"
21-
viewController.tabBarItem = UITabBarItem(tabBarSystemItem: UITabBarSystemItem.recents, tag: 0)
22-
21+
viewController.tabBarItem = UITabBarItem(tabBarSystemItem: .recents, tag: 0)
22+
2323
let tabBarController = UITabBarController()
2424
tabBarController.viewControllers = [
2525
viewController
2626
]
27-
27+
2828
// deprecated
2929
// window?.rootViewController = TinyConsoleController(rootViewController: tabBarController)
30-
31-
32-
30+
3331
// TinyConsole with default gesture recognizers
3432
// window?.rootViewController = TinyConsole.createViewController(rootViewController: tabBarController)
35-
33+
3634
// TinyConsole with custom gesture reconizers
3735
window?.rootViewController = TinyConsole.createViewController(rootViewController: tabBarController, withDefaultGestureConfiguration: false)
3836
// single tap
@@ -47,52 +45,49 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
4745
// swipe
4846
let swipeGestureRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(consoleSwiped))
4947
TinyConsole.addGestureRecognizer(swipeGestureRecognizer)
50-
48+
5149
// Calling this func to set back to default configuration
5250
// TinyConsole.useDefaultGestureConfiguration()
53-
51+
5452
window?.makeKeyAndVisible()
55-
53+
5654
return true
5755
}
58-
59-
func consoleTapped(sender: UITapGestureRecognizer) {
56+
57+
@objc func consoleTapped(sender _: UITapGestureRecognizer) {
6058
TinyConsole.print("console tapped, do nothing", global: true)
6159
}
62-
63-
func consoleDoubleTapped(sender: UITapGestureRecognizer) {
60+
61+
@objc func consoleDoubleTapped(sender _: UITapGestureRecognizer) {
6462
TinyConsole.print("console double tapped, do nothing", global: true)
6563
}
66-
67-
func consoleSwiped(sender: UISwipeGestureRecognizer) {
64+
65+
@objc func consoleSwiped(sender _: UISwipeGestureRecognizer) {
6866
TinyConsole.print("console swipped, change to red view controller", global: true)
6967
let vc = UIViewController()
7068
vc.view.backgroundColor = UIColor.red
7169
TinyConsole.set(rootViewController: vc)
7270
}
7371

74-
func applicationWillResignActive(_ application: UIApplication) {
72+
func applicationWillResignActive(_: UIApplication) {
7573
// 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.
7674
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
7775
}
7876

79-
func applicationDidEnterBackground(_ application: UIApplication) {
77+
func applicationDidEnterBackground(_: UIApplication) {
8078
// 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.
8179
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
8280
}
8381

84-
func applicationWillEnterForeground(_ application: UIApplication) {
82+
func applicationWillEnterForeground(_: UIApplication) {
8583
// 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.
8684
}
8785

88-
func applicationDidBecomeActive(_ application: UIApplication) {
86+
func applicationDidBecomeActive(_: UIApplication) {
8987
// 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.
9088
}
9189

92-
func applicationWillTerminate(_ application: UIApplication) {
90+
func applicationWillTerminate(_: UIApplication) {
9391
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
9492
}
95-
96-
9793
}
98-

TinyConsole-Example/DataSource.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ class MainTableViewDataSource: NSObject, UITableViewDataSource {
1212
func registerCellsForTableView(_ tableView: UITableView) {
1313
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "default")
1414
}
15-
16-
func numberOfSections(in tableView: UITableView) -> Int {
15+
16+
func numberOfSections(in _: UITableView) -> Int {
1717
return 1
1818
}
19-
20-
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
19+
20+
func tableView(_: UITableView, numberOfRowsInSection _: Int) -> Int {
2121
return 30
2222
}
23-
23+
2424
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
2525
let cell = tableView.dequeueReusableCell(withIdentifier: "default", for: indexPath)
2626
cell.textLabel?.text = "Row \(indexPath.row)"

TinyConsole-Example/Delegate.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
//
77
//
88

9-
import UIKit
109
import TinyConsole
10+
import UIKit
1111

1212
class MainTableViewDelegate: NSObject, UITableViewDelegate {
13-
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
13+
func tableView(_: UITableView, didSelectRowAt indexPath: IndexPath) {
1414
TinyConsole.print("Tapped on \(indexPath.row)")
1515
}
1616
}

TinyConsole-Example/MainViewController.swift

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,66 +6,66 @@
66
//
77
//
88

9-
import UIKit
109
import TinyConsole
10+
import UIKit
1111

1212
class MainViewController: UITableViewController {
1313
var tableViewDelegate: UITableViewDelegate
1414
var tableViewDataSource: UITableViewDataSource
15-
15+
1616
init() {
1717
tableViewDelegate = MainTableViewDelegate()
1818
tableViewDataSource = MainTableViewDataSource()
19-
super.init(style: UITableViewStyle.plain)
19+
super.init(style: .plain)
2020
}
21-
22-
required init?(coder aDecoder: NSCoder) {
21+
22+
required init?(coder _: NSCoder) {
2323
fatalError("init(coder:) has not been implemented")
2424
}
25-
25+
2626
override func viewDidLoad() {
27-
(tableViewDataSource as? MainTableViewDataSource)?.registerCellsForTableView(self.tableView)
27+
(tableViewDataSource as? MainTableViewDataSource)?.registerCellsForTableView(tableView)
2828
tableView.delegate = tableViewDelegate
2929
tableView.dataSource = tableViewDataSource
30-
30+
3131
super.viewDidLoad()
3232
view.backgroundColor = UIColor.white
33-
33+
3434
setupNavigationItems()
3535
}
3636

3737
override func viewDidAppear(_ animated: Bool) {
3838
super.viewDidAppear(animated)
39-
39+
4040
TinyConsole.print("Welcome to TinyConsole")
4141
TinyConsole.addMarker()
4242
TinyConsole.print("NOW", color: UIColor.red)
4343
TinyConsole.print("IN", color: UIColor.green)
4444
TinyConsole.print("COLOR", color: UIColor.blue)
4545
TinyConsole.addMarker()
4646
}
47-
47+
4848
func setupNavigationItems() {
4949
navigationItem.leftBarButtonItems = [
50-
UIBarButtonItem(title: "Add Log", style: UIBarButtonItemStyle.plain, target: self, action: #selector(addLog))
50+
UIBarButtonItem(title: "Add Log", style: .plain, target: self, action: #selector(addLog))
5151
]
5252
navigationItem.rightBarButtonItems = [
53-
UIBarButtonItem( title: "Add Marker", style: UIBarButtonItemStyle.plain, target: self, action: #selector(addMarker)),
54-
UIBarButtonItem( title: "Clear", style: UIBarButtonItemStyle.plain, target: self, action: #selector(clear)),
53+
UIBarButtonItem(title: "Add Marker", style: .plain, target: self, action: #selector(addMarker)),
54+
UIBarButtonItem(title: "Clear", style: .plain, target: self, action: #selector(clear))
5555
]
5656
}
5757
}
5858

5959
extension MainViewController {
60-
func addLog() {
60+
@objc func addLog() {
6161
TinyConsole.print("Hello World")
6262
}
63-
64-
func clear() {
63+
64+
@objc func clear() {
6565
TinyConsole.clear()
6666
}
67-
68-
func addMarker() {
67+
68+
@objc func addMarker() {
6969
TinyConsole.addMarker()
7070
}
7171
}

TinyConsole.xcodeproj/project.pbxproj

Lines changed: 63 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,16 @@
191191
isa = PBXProject;
192192
attributes = {
193193
LastSwiftUpdateCheck = 0810;
194-
LastUpgradeCheck = 0810;
194+
LastUpgradeCheck = 1000;
195195
TargetAttributes = {
196196
4585FDCA1DEC54B800DDF5EB = {
197197
CreatedOnToolsVersion = 8.1;
198-
LastSwiftMigration = 0810;
198+
LastSwiftMigration = 1000;
199199
ProvisioningStyle = Automatic;
200200
};
201201
4585FDE21DEC58BB00DDF5EB = {
202202
CreatedOnToolsVersion = 8.1;
203+
LastSwiftMigration = 1000;
203204
ProvisioningStyle = Manual;
204205
};
205206
};
@@ -289,12 +290,64 @@
289290
4585FDC41DEC532500DDF5EB /* Debug */ = {
290291
isa = XCBuildConfiguration;
291292
buildSettings = {
293+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
294+
CLANG_WARN_BOOL_CONVERSION = YES;
295+
CLANG_WARN_COMMA = YES;
296+
CLANG_WARN_CONSTANT_CONVERSION = YES;
297+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
298+
CLANG_WARN_EMPTY_BODY = YES;
299+
CLANG_WARN_ENUM_CONVERSION = YES;
300+
CLANG_WARN_INFINITE_RECURSION = YES;
301+
CLANG_WARN_INT_CONVERSION = YES;
302+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
303+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
304+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
305+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
306+
CLANG_WARN_STRICT_PROTOTYPES = YES;
307+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
308+
CLANG_WARN_UNREACHABLE_CODE = YES;
309+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
310+
ENABLE_STRICT_OBJC_MSGSEND = YES;
311+
ENABLE_TESTABILITY = YES;
312+
GCC_NO_COMMON_BLOCKS = YES;
313+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
314+
GCC_WARN_ABOUT_RETURN_TYPE = YES;
315+
GCC_WARN_UNDECLARED_SELECTOR = YES;
316+
GCC_WARN_UNINITIALIZED_AUTOS = YES;
317+
GCC_WARN_UNUSED_FUNCTION = YES;
318+
GCC_WARN_UNUSED_VARIABLE = YES;
319+
ONLY_ACTIVE_ARCH = YES;
292320
};
293321
name = Debug;
294322
};
295323
4585FDC51DEC532500DDF5EB /* Release */ = {
296324
isa = XCBuildConfiguration;
297325
buildSettings = {
326+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
327+
CLANG_WARN_BOOL_CONVERSION = YES;
328+
CLANG_WARN_COMMA = YES;
329+
CLANG_WARN_CONSTANT_CONVERSION = YES;
330+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
331+
CLANG_WARN_EMPTY_BODY = YES;
332+
CLANG_WARN_ENUM_CONVERSION = YES;
333+
CLANG_WARN_INFINITE_RECURSION = YES;
334+
CLANG_WARN_INT_CONVERSION = YES;
335+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
336+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
337+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
338+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
339+
CLANG_WARN_STRICT_PROTOTYPES = YES;
340+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
341+
CLANG_WARN_UNREACHABLE_CODE = YES;
342+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
343+
ENABLE_STRICT_OBJC_MSGSEND = YES;
344+
GCC_NO_COMMON_BLOCKS = YES;
345+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
346+
GCC_WARN_ABOUT_RETURN_TYPE = YES;
347+
GCC_WARN_UNDECLARED_SELECTOR = YES;
348+
GCC_WARN_UNINITIALIZED_AUTOS = YES;
349+
GCC_WARN_UNUSED_FUNCTION = YES;
350+
GCC_WARN_UNUSED_VARIABLE = YES;
298351
};
299352
name = Release;
300353
};
@@ -320,7 +373,7 @@
320373
CLANG_WARN_UNREACHABLE_CODE = YES;
321374
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
322375
CODE_SIGN_IDENTITY = "";
323-
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
376+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
324377
COPY_PHASE_STRIP = NO;
325378
CURRENT_PROJECT_VERSION = 1;
326379
DEBUG_INFORMATION_FORMAT = dwarf;
@@ -357,7 +410,7 @@
357410
SKIP_INSTALL = YES;
358411
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
359412
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
360-
SWIFT_VERSION = 3.0;
413+
SWIFT_VERSION = 4.2;
361414
TARGETED_DEVICE_FAMILY = "1,2";
362415
VERSIONING_SYSTEM = "apple-generic";
363416
VERSION_INFO_PREFIX = "";
@@ -386,7 +439,7 @@
386439
CLANG_WARN_UNREACHABLE_CODE = YES;
387440
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
388441
CODE_SIGN_IDENTITY = "";
389-
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
442+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
390443
COPY_PHASE_STRIP = NO;
391444
CURRENT_PROJECT_VERSION = 1;
392445
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
@@ -415,7 +468,7 @@
415468
SDKROOT = iphoneos;
416469
SKIP_INSTALL = YES;
417470
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
418-
SWIFT_VERSION = 3.0;
471+
SWIFT_VERSION = 4.2;
419472
TARGETED_DEVICE_FAMILY = "1,2";
420473
VALIDATE_PRODUCT = YES;
421474
VERSIONING_SYSTEM = "apple-generic";
@@ -476,7 +529,8 @@
476529
SDKROOT = iphoneos;
477530
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
478531
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
479-
SWIFT_VERSION = 3.0;
532+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
533+
SWIFT_VERSION = 4.2;
480534
TARGETED_DEVICE_FAMILY = "1,2";
481535
};
482536
name = Debug;
@@ -526,7 +580,8 @@
526580
PRODUCT_NAME = "$(TARGET_NAME)";
527581
SDKROOT = iphoneos;
528582
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
529-
SWIFT_VERSION = 3.0;
583+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
584+
SWIFT_VERSION = 4.2;
530585
TARGETED_DEVICE_FAMILY = "1,2";
531586
VALIDATE_PRODUCT = YES;
532587
};

0 commit comments

Comments
 (0)