Skip to content

Commit f83a72a

Browse files
committed
Fix build errors and improve code quality
Address CI build failures and additional code review suggestions: **Build Fixes:** - Add CustomStringConvertible conformance to SimpleClickEngine.ClickType - Fix NSSize os.log interpolation by using String(describing:) **Code Quality Improvements:** - Create LoggingConstants enum for shared subsystem string - Prevent typos and ensure consistency across logging - Derive cursor resource file name from cursorDimension constant - Move cursor properties to top of setupCustomCursor() for easy modification This ensures the code builds cleanly and follows Swift best practices for maintainability and consistency.
1 parent 5ad50d3 commit f83a72a

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//
2+
// LoggingConstants.swift
3+
// ClickIt Lite
4+
//
5+
// Shared logging constants for consistent logging across the Lite module.
6+
//
7+
8+
import Foundation
9+
10+
/// Shared logging constants to ensure consistency and prevent typos
11+
enum LoggingConstants {
12+
/// The subsystem identifier for all ClickIt Lite logging
13+
static let subsystem = "com.jsonify.clickit.lite"
14+
}

β€ŽSources/ClickIt/Lite/SimpleClickEngine.swiftβ€Ž

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,21 @@ final class SimpleClickEngine {
1515

1616
// MARK: - Types
1717

18-
enum ClickType {
18+
enum ClickType: CustomStringConvertible {
1919
case left
2020
case right
21+
22+
var description: String {
23+
switch self {
24+
case .left: return "left"
25+
case .right: return "right"
26+
}
27+
}
2128
}
2229

2330
// MARK: - Properties
2431

25-
private let logger = Logger(subsystem: "com.jsonify.clickit.lite", category: "SimpleClickEngine")
32+
private let logger = Logger(subsystem: LoggingConstants.subsystem, category: "SimpleClickEngine")
2633
private var isRunning = false
2734
private var clickTask: Task<Void, Never>?
2835
private var clickCount = 0

β€ŽSources/ClickIt/Lite/SimpleCursorManager.swiftβ€Ž

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class SimpleCursorManager {
1717

1818
// MARK: - Properties
1919

20-
private let logger = Logger(subsystem: "com.jsonify.clickit.lite", category: "SimpleCursorManager")
20+
private let logger = Logger(subsystem: LoggingConstants.subsystem, category: "SimpleCursorManager")
2121
private var customCursor: NSCursor?
2222
private var originalCursor: NSCursor?
2323
private var cursorUpdateTimer: Timer?
@@ -101,6 +101,10 @@ class SimpleCursorManager {
101101
}
102102

103103
private func setupCustomCursor() {
104+
// Define cursor properties at the top for easy modification
105+
let cursorDimension: CGFloat = 64
106+
let cursorImageName = "target-\(Int(cursorDimension))"
107+
104108
// Debug: Log bundle path
105109
logger.debug("πŸ” Bundle path: \(Bundle.main.bundlePath)")
106110
logger.debug("πŸ” Resource path: \(Bundle.main.resourcePath ?? "nil")")
@@ -110,8 +114,8 @@ class SimpleCursorManager {
110114
logger.debug("πŸ” Using bundle: \(bundle.bundlePath)")
111115

112116
// Try to load the target image from resources
113-
guard let imageURL = bundle.url(forResource: "target-64", withExtension: "png") else {
114-
logger.error("❌ Failed to find target-64.png in bundle")
117+
guard let imageURL = bundle.url(forResource: cursorImageName, withExtension: "png") else {
118+
logger.error("❌ Failed to find \(cursorImageName).png in bundle")
115119
logger.error("πŸ” Searched in: \(bundle.bundleURL)")
116120

117121
// Try to list all resources
@@ -133,10 +137,9 @@ class SimpleCursorManager {
133137
return
134138
}
135139

136-
logger.debug("βœ… NSImage loaded, original size: \(image.size)")
140+
logger.debug("βœ… NSImage loaded, original size: \(String(describing: image.size))")
137141

138142
// Set the cursor size
139-
let cursorDimension: CGFloat = 64
140143
image.size = NSSize(width: cursorDimension, height: cursorDimension)
141144

142145
// Create cursor with hotspot at center

0 commit comments

Comments
Β (0)