From f41f389d3a87422f8942d293c27fcdb476d8c6e0 Mon Sep 17 00:00:00 2001 From: Nonnus Date: Sat, 16 Sep 2017 15:58:00 +0200 Subject: [PATCH] migrated to swift4, bumped version to 1.0.7 --- .travis.yml | 6 ++--- BuildTimeAnalyzer.xcodeproj/project.pbxproj | 26 ++++++++++++++----- .../xcschemes/BuildTimeAnalyzer.xcscheme | 4 ++- BuildTimeAnalyzer/AppDelegate.swift | 10 +++---- BuildTimeAnalyzer/CompileMeasure.swift | 16 ++++++------ BuildTimeAnalyzer/Info.plist | 2 +- BuildTimeAnalyzer/LogProcessor.swift | 12 ++++----- BuildTimeAnalyzer/ProjectSelection.swift | 2 +- BuildTimeAnalyzer/ViewController.swift | 20 +++++++------- 9 files changed, 56 insertions(+), 42 deletions(-) diff --git a/.travis.yml b/.travis.yml index 301f564..42e96cd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,3 @@ -language: objective-c -osx_image: xcode8.2 -script: xcodebuild -project BuildTimeAnalyzer.xcodeproj -scheme BuildTimeAnalyzer build test \ No newline at end of file +language: swift +osx_image: xcode9 +script: xcodebuild -project BuildTimeAnalyzer.xcodeproj -scheme BuildTimeAnalyzer build test diff --git a/BuildTimeAnalyzer.xcodeproj/project.pbxproj b/BuildTimeAnalyzer.xcodeproj/project.pbxproj index da64aeb..8dc7c65 100644 --- a/BuildTimeAnalyzer.xcodeproj/project.pbxproj +++ b/BuildTimeAnalyzer.xcodeproj/project.pbxproj @@ -246,16 +246,16 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 0800; + LastUpgradeCheck = 0900; ORGANIZATIONNAME = "Cane Media Ltd"; TargetAttributes = { 2AF8213F1D21D6B900D65186 = { CreatedOnToolsVersion = 7.3.1; - LastSwiftMigration = 0800; + LastSwiftMigration = 0900; }; 2AF8214E1D21D6B900D65186 = { CreatedOnToolsVersion = 7.3.1; - LastSwiftMigration = 0800; + LastSwiftMigration = 0900; TestTargetID = 2AF8213F1D21D6B900D65186; }; }; @@ -350,14 +350,20 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 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_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + 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; @@ -397,14 +403,20 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 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_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + 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; @@ -438,7 +450,7 @@ PRODUCT_BUNDLE_IDENTIFIER = uk.co.canemedia.BuildTimeAnalyzer; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "BuildTimeAnalyzerTests-Bridging-Header.h"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -452,7 +464,7 @@ PRODUCT_BUNDLE_IDENTIFIER = uk.co.canemedia.BuildTimeAnalyzer; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "BuildTimeAnalyzerTests-Bridging-Header.h"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -468,7 +480,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "BuildTimeAnalyzerTests-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/BuildTimeAnalyzer.app/Contents/MacOS/BuildTimeAnalyzer"; }; name = Debug; @@ -484,7 +496,7 @@ PRODUCT_BUNDLE_IDENTIFIER = uk.co.canemedia.BuildTimeAnalyzerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "BuildTimeAnalyzerTests-Bridging-Header.h"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/BuildTimeAnalyzer.app/Contents/MacOS/BuildTimeAnalyzer"; }; name = Release; diff --git a/BuildTimeAnalyzer.xcodeproj/xcshareddata/xcschemes/BuildTimeAnalyzer.xcscheme b/BuildTimeAnalyzer.xcodeproj/xcshareddata/xcschemes/BuildTimeAnalyzer.xcscheme index dd7aabe..1248a9e 100644 --- a/BuildTimeAnalyzer.xcodeproj/xcshareddata/xcschemes/BuildTimeAnalyzer.xcscheme +++ b/BuildTimeAnalyzer.xcodeproj/xcshareddata/xcschemes/BuildTimeAnalyzer.xcscheme @@ -1,6 +1,6 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.0.6 + 1.0.7 CFBundleSignature ???? CFBundleVersion diff --git a/BuildTimeAnalyzer/LogProcessor.swift b/BuildTimeAnalyzer/LogProcessor.swift index 70a8522..014e74f 100644 --- a/BuildTimeAnalyzer/LogProcessor.swift +++ b/BuildTimeAnalyzer/LogProcessor.swift @@ -41,7 +41,7 @@ extension LogProcessorProtocol { processingDidStart() while let nextRange = text.rangeOfCharacter(from: characterSet, options: [], range: remainingRange) { - let text = text.substring(with: remainingRange.lowerBound..= 2 ? trimPrefixes(code[1]) : "-" if let path = code.first?.trimmingCharacters(in: characterSet), let measure = CompileMeasure(time: entry.time, rawPath: path, code: method, references: entry.references) { @@ -100,7 +100,7 @@ extension LogProcessorProtocol { var code = code ["@objc ", "final ", "@IBAction "].forEach { (prefix) in if code.hasPrefix(prefix) { - code = code.substring(from: code.index(code.startIndex, offsetBy: prefix.characters.count)) + code = String(code[code.index(code.startIndex, offsetBy: prefix.count)...]) } } return code @@ -130,7 +130,7 @@ class LogProcessor: NSObject, LogProcessorProtocol { } } - func timerCallback(_ timer: Timer) { + @objc func timerCallback(_ timer: Timer) { updateResults(didComplete: false, didCancel: false) } } diff --git a/BuildTimeAnalyzer/ProjectSelection.swift b/BuildTimeAnalyzer/ProjectSelection.swift index 9cb6c02..d021f84 100644 --- a/BuildTimeAnalyzer/ProjectSelection.swift +++ b/BuildTimeAnalyzer/ProjectSelection.swift @@ -54,7 +54,7 @@ extension ProjectSelection: NSTableViewDelegate { func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? { guard let tableColumn = tableColumn, let columnIndex = tableView.tableColumns.index(of: tableColumn) else { return nil } - let cellView = tableView.make(withIdentifier: "Cell\(columnIndex)", owner: self) as? NSTableCellView + let cellView = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "Cell\(columnIndex)"), owner: self) as? NSTableCellView let source = dataSource[row] var value = "" diff --git a/BuildTimeAnalyzer/ViewController.swift b/BuildTimeAnalyzer/ViewController.swift index a4cc501..09a2475 100644 --- a/BuildTimeAnalyzer/ViewController.swift +++ b/BuildTimeAnalyzer/ViewController.swift @@ -49,7 +49,7 @@ class ViewController: NSViewController { projectSelection.delegate = self projectSelection.listFolders() - NotificationCenter.default.addObserver(self, selector: #selector(windowWillClose(notification:)), name: .NSWindowWillClose, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(windowWillClose(notification:)), name: NSWindow.willCloseNotification, object: nil) } override func viewWillAppear() { @@ -67,7 +67,7 @@ class ViewController: NSViewController { makeWindowTopMost(topMost: false) } - func windowWillClose(notification: NSNotification) { + @objc func windowWillClose(notification: NSNotification) { guard let object = notification.object, !(object is NSPanel) else { return } NotificationCenter.default.removeObserver(self) @@ -142,26 +142,26 @@ class ViewController: NSViewController { } func makeWindowTopMost(topMost: Bool) { - if let window = NSApplication.shared().windows.first { + if let window = NSApplication.shared.windows.first { let level: CGWindowLevelKey = topMost ? .floatingWindow : .normalWindow - window.level = Int(CGWindowLevelForKey(level)) + window.level = NSWindow.Level(rawValue: Int(CGWindowLevelForKey(level))) } } // MARK: Actions @IBAction func perFileCheckboxClicked(_ sender: NSButton) { - dataSource = sender.state == 0 ? perFunctionTimes : perFileTimes + dataSource = sender.state.rawValue == 0 ? perFunctionTimes : perFileTimes tableView.reloadData() } @IBAction func clipboardButtonClicked(_ sender: AnyObject) { - NSPasteboard.general().clearContents() - NSPasteboard.general().writeObjects(["-Xfrontend -debug-time-function-bodies" as NSPasteboardWriting]) + NSPasteboard.general.clearContents() + NSPasteboard.general.writeObjects(["-Xfrontend -debug-time-function-bodies" as NSPasteboardWriting]) } @IBAction func visitDerivedData(_ sender: AnyObject) { - NSWorkspace.shared().openFile(derivedDataTextField.stringValue) + NSWorkspace.shared.openFile(derivedDataTextField.stringValue) } @@ -283,7 +283,7 @@ extension ViewController: NSTableViewDataSource { func tableView(_ tableView: NSTableView, shouldSelectRow row: Int) -> Bool { let item = filteredData?[row] ?? dataSource[row] - NSWorkspace.shared().openFile(item.path) + NSWorkspace.shared.openFile(item.path) let gotoLineScript = @@ -312,7 +312,7 @@ extension ViewController: NSTableViewDelegate { func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? { guard let tableColumn = tableColumn, let columnIndex = tableView.tableColumns.index(of: tableColumn) else { return nil } - let result = tableView.make(withIdentifier: "Cell\(columnIndex)", owner: self) as? NSTableCellView + let result = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "Cell\(columnIndex)"), owner: self) as? NSTableCellView result?.textField?.stringValue = filteredData?[row][columnIndex] ?? dataSource[row][columnIndex] return result