Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion BuildTimeAnalyzer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 1020;
LastUpgradeCheck = 1420;
ORGANIZATIONNAME = "Cane Media Ltd";
TargetAttributes = {
2AF8213F1D21D6B900D65186 = {
Expand Down Expand Up @@ -373,13 +373,15 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = 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;
CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand Down Expand Up @@ -429,13 +431,15 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = 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;
CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand All @@ -458,9 +462,12 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "-";
COMBINE_HIDPI_IMAGES = YES;
DEAD_CODE_STRIPPING = YES;
INFOPLIST_FILE = BuildTimeAnalyzer/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 13.0;
PRODUCT_BUNDLE_IDENTIFIER = uk.co.canemedia.BuildTimeAnalyzer;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "BuildTimeAnalyzerTests-Bridging-Header.h";
Expand All @@ -472,9 +479,12 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "-";
COMBINE_HIDPI_IMAGES = YES;
DEAD_CODE_STRIPPING = YES;
INFOPLIST_FILE = BuildTimeAnalyzer/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 13.0;
PRODUCT_BUNDLE_IDENTIFIER = uk.co.canemedia.BuildTimeAnalyzer;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "BuildTimeAnalyzerTests-Bridging-Header.h";
Expand All @@ -488,8 +498,10 @@
BUNDLE_LOADER = "$(TEST_HOST)";
CLANG_ENABLE_MODULES = YES;
COMBINE_HIDPI_IMAGES = YES;
DEAD_CODE_STRIPPING = YES;
INFOPLIST_FILE = BuildTimeAnalyzerTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 13.0;
PRODUCT_BUNDLE_IDENTIFIER = uk.co.canemedia.BuildTimeAnalyzerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "BuildTimeAnalyzerTests-Bridging-Header.h";
Expand All @@ -505,8 +517,10 @@
BUNDLE_LOADER = "$(TEST_HOST)";
CLANG_ENABLE_MODULES = YES;
COMBINE_HIDPI_IMAGES = YES;
DEAD_CODE_STRIPPING = YES;
INFOPLIST_FILE = BuildTimeAnalyzerTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 13.0;
PRODUCT_BUNDLE_IDENTIFIER = uk.co.canemedia.BuildTimeAnalyzerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "BuildTimeAnalyzerTests-Bridging-Header.h";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
version = "1.3">
LastUpgradeVersion = "1420"
version = "1.8">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
Expand All @@ -27,6 +27,15 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2AF8213F1D21D6B900D65186"
BuildableName = "BuildTimeAnalyzer.app"
BlueprintName = "BuildTimeAnalyzer"
ReferencedContainer = "container:BuildTimeAnalyzer.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -39,17 +48,6 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2AF8213F1D21D6B900D65186"
BuildableName = "BuildTimeAnalyzer.app"
BlueprintName = "BuildTimeAnalyzer"
ReferencedContainer = "container:BuildTimeAnalyzer.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -72,8 +70,6 @@
ReferencedContainer = "container:BuildTimeAnalyzer.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
18 changes: 9 additions & 9 deletions BuildTimeAnalyzer/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import Cocoa

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
final class AppDelegate: NSObject, NSApplicationDelegate {

@IBOutlet weak var projectSelectionMenuItem: NSMenuItem!
@IBOutlet weak var buildTimesMenuItem: NSMenuItem!
@IBOutlet weak var alwaysInFrontMenuItem: NSMenuItem!
@IBOutlet private weak var projectSelectionMenuItem: NSMenuItem!
@IBOutlet private weak var buildTimesMenuItem: NSMenuItem!
@IBOutlet private weak var alwaysInFrontMenuItem: NSMenuItem!

var viewController: ViewController? {
private var viewController: ViewController? {
return NSApplication.shared.mainWindow?.contentViewController as? ViewController
}

Expand All @@ -27,26 +27,26 @@ class AppDelegate: NSObject, NSApplicationDelegate {

// MARK: Actions

@IBAction func navigateToProjectSelection(_ sender: NSMenuItem) {
@IBAction private func navigateToProjectSelection(_ sender: NSMenuItem) {
configureMenuItems(showBuildTimesMenuItem: true)

viewController?.cancelProcessing()
viewController?.showInstructions(true)
}

@IBAction func navigateToBuildTimes(_ sender: NSMenuItem) {
@IBAction private func navigateToBuildTimes(_ sender: NSMenuItem) {
configureMenuItems(showBuildTimesMenuItem: false)
viewController?.showInstructions(false)
}

@IBAction func visitGitHubPage(_ sender: AnyObject) {
@IBAction private func visitGitHubPage(_ sender: AnyObject) {
let path = "https://github.com/RobertGummesson/BuildTimeAnalyzer-for-Xcode"
if let url = URL(string: path) {
NSWorkspace.shared.open(url)
}
}

@IBAction func toggleAlwaysInFront(_ sender: NSMenuItem) {
@IBAction private func toggleAlwaysInFront(_ sender: NSMenuItem) {
let alwaysInFront = sender.state == .off

sender.state = alwaysInFront ? .on : .off
Expand Down
12 changes: 7 additions & 5 deletions BuildTimeAnalyzer/BuildManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

import Cocoa

protocol BuildManagerDelegate: class {
protocol BuildManagerDelegate: AnyObject {
func derivedDataDidChange()
func buildManager(_ buildManager: BuildManager, shouldParseLogWithDatabase database: XcodeDatabase)
}

class BuildManager: NSObject {
final class BuildManager: NSObject {

weak var delegate: BuildManagerDelegate?

Expand All @@ -37,12 +37,12 @@ class BuildManager: NSObject {
derivedDataDirectoryMonitor.stopMonitoring()
}

func database(forFolder URL: URL) -> XcodeDatabase? {
private func database(forFolder URL: URL) -> XcodeDatabase? {
let databaseURL = URL.appendingPathComponent("Cache.db")
return XcodeDatabase(fromPath: databaseURL.path)
}

func processDerivedData() {
private func processDerivedData() {
guard let mostRecent = DerivedDataManager.derivedData().first else { return }

let logFolder = mostRecent.url.appendingPathComponent("Logs/Build").path
Expand All @@ -52,7 +52,7 @@ class BuildManager: NSObject {
logFolderDirectoryMonitor.startMonitoring(path: logFolder)
}

func processLogFolder(with url: URL) {
private func processLogFolder(with url: URL) {
guard let activeDatabase = database(forFolder: url),
activeDatabase.isBuildType,
activeDatabase != currentDataBase else { return }
Expand All @@ -62,6 +62,8 @@ class BuildManager: NSObject {
}
}

// MARK: - DirectoryMonitorDelegate

extension BuildManager: DirectoryMonitorDelegate {
func directoryMonitorDidObserveChange(_ directoryMonitor: DirectoryMonitor, isDerivedData: Bool) {
if isDerivedData {
Expand Down
6 changes: 3 additions & 3 deletions BuildTimeAnalyzer/CompileMeasure.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import Foundation

@objcMembers class CompileMeasure: NSObject {
@objcMembers final class CompileMeasure: NSObject {

dynamic var time: Double
var path: String
Expand All @@ -15,12 +15,12 @@ import Foundation

private var locationArray: [Int]

public enum Order: String {
enum Order: String {
case filename
case time
}

var fileAndLine: String {
private var fileAndLine: String {
return "\(filename):\(locationArray[0])"
}

Expand Down
5 changes: 2 additions & 3 deletions BuildTimeAnalyzer/DerivedDataManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

import Foundation

class DerivedDataManager {

final class DerivedDataManager {
static func derivedData() -> [File] {
let url = URL(fileURLWithPath: UserSettings.derivedDataLocation)

Expand All @@ -23,7 +22,7 @@ class DerivedDataManager {
}.sorted{ $0.date > $1.date }
}

static func listFolders(at url: URL) -> [URL] {
private static func listFolders(at url: URL) -> [URL] {
let fileManager = FileManager.default
let keys = [URLResourceKey.nameKey, URLResourceKey.isDirectoryKey]
let options: FileManager.DirectoryEnumerationOptions = [.skipsHiddenFiles, .skipsPackageDescendants, .skipsSubdirectoryDescendants]
Expand Down
22 changes: 10 additions & 12 deletions BuildTimeAnalyzer/DirectoryMonitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,20 @@

import Foundation

protocol DirectoryMonitorDelegate: class {
protocol DirectoryMonitorDelegate: AnyObject {
func directoryMonitorDidObserveChange(_ directoryMonitor: DirectoryMonitor, isDerivedData: Bool)
}

class DirectoryMonitor {
var dispatchQueue: DispatchQueue
final class DirectoryMonitor {
private var dispatchQueue: DispatchQueue
private var fileDescriptor: Int32 = -1
private var dispatchSource: DispatchSourceFileSystemObject?
private var isDerivedData: Bool
private var lastDerivedDataDate = Date()
private var isMonitoringDates = false

weak var delegate: DirectoryMonitorDelegate?

var fileDescriptor: Int32 = -1
var dispatchSource: DispatchSourceFileSystemObject?
var isDerivedData: Bool
var path: String?
var timer: Timer?
var lastDerivedDataDate = Date()
var isMonitoringDates = false
weak var delegate: DirectoryMonitorDelegate?

init(isDerivedData: Bool) {
self.isDerivedData = isDerivedData
Expand Down Expand Up @@ -63,7 +61,7 @@ class DirectoryMonitor {
path = nil
}

func monitorModificationDates() {
private func monitorModificationDates() {
if let date = DerivedDataManager.derivedData().first?.date, date > lastDerivedDataDate {
lastDerivedDataDate = date
self.delegate?.directoryMonitorDidObserveChange(self, isDerivedData: self.isDerivedData)
Expand Down
Loading