Skip to content

Commit b39e307

Browse files
Fix build scripts for m1 mac (MonitorControl#1037)
1 parent 75cd15c commit b39e307

File tree

9 files changed

+23
-23
lines changed

9 files changed

+23
-23
lines changed

MonitorControl.xcodeproj/project.pbxproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@
515515
);
516516
runOnlyForDeploymentPostprocessing = 0;
517517
shellPath = /bin/sh;
518-
shellScript = "if which swiftformat >/dev/null; then\n swiftformat .\nelse\n echo \"warning: SwiftFormat not installed, download from https://github.com/nicklockwood/SwiftFormat\" >&2\nfi\n";
518+
shellScript = "export PATH=\"$PATH:/opt/homebrew/bin\"\nif which swiftformat >/dev/null; then\n swiftformat .\nelse\n echo \"warning: SwiftFormat not installed, download from https://github.com/nicklockwood/SwiftFormat\" >&2\nfi\n";
519519
};
520520
28F6A5802283515F00A4ADCD /* Increase Build Number */ = {
521521
isa = PBXShellScriptBuildPhase;
@@ -569,7 +569,7 @@
569569
);
570570
runOnlyForDeploymentPostprocessing = 0;
571571
shellPath = /bin/sh;
572-
shellScript = "if which bartycrouch > /dev/null; then\n bartycrouch update -x\n bartycrouch lint -x\nelse\n echo \"warning: BartyCrouch not installed, download it from https://github.com/Flinesoft/BartyCrouch\"\nfi\n";
572+
shellScript = "export PATH=\"$PATH:/opt/homebrew/bin\"\nif which bartycrouch > /dev/null; then\n bartycrouch update -x\n bartycrouch lint -x\nelse\n echo \"warning: BartyCrouch not installed, download it from https://github.com/Flinesoft/BartyCrouch\"\nfi\n";
573573
};
574574
F03A8DF01FFB9D4C0034DC27 /* [Lint] Run SwiftLint */ = {
575575
isa = PBXShellScriptBuildPhase;
@@ -583,7 +583,7 @@
583583
);
584584
runOnlyForDeploymentPostprocessing = 0;
585585
shellPath = /bin/sh;
586-
shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\" >&2\nfi\n";
586+
shellScript = "export PATH=\"$PATH:/opt/homebrew/bin\"\nif which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\" >&2\nfi\n";
587587
};
588588
/* End PBXShellScriptBuildPhase section */
589589

MonitorControl/Support/Arm64DDC.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class Arm64DDC: NSObject {
7575

7676
// Performs DDC read or write
7777
public static func performDDCCommunication(service: IOAVService?, send: inout [UInt8], reply: inout [UInt8], writeSleepTime: UInt32 = 10000, numofWriteCycles: UInt8 = 2, readSleepTime: UInt32 = 10000, numOfRetryAttemps: UInt8 = 3, retrySleepTime: UInt32 = 20000) -> Bool {
78-
var success: Bool = false
78+
var success = false
7979
guard service != nil else {
8080
return success
8181
}
@@ -133,8 +133,8 @@ class Arm64DDC: NSObject {
133133

134134
// Scores the likelihood of a display match based on EDID UUID, ProductName and SerialNumber from in ioreg, compared to DisplayCreateInfoDictionary.
135135
private static func ioregMatchScore(displayID: CGDirectDisplayID, ioregEdidUUID: String, ioregProductName: String = "", ioregSerialNumber: Int64 = 0, serviceLocation: Int = 0) -> Int {
136-
var matchScore: Int = 0
137-
if let dictionary = (CoreDisplay_DisplayCreateInfoDictionary(displayID))?.takeRetainedValue() as NSDictionary? {
136+
var matchScore = 0
137+
if let dictionary = CoreDisplay_DisplayCreateInfoDictionary(displayID)?.takeRetainedValue() as NSDictionary? {
138138
if let kDisplayYearOfManufacture = dictionary[kDisplayYearOfManufacture] as? Int64, let kDisplayWeekOfManufacture = dictionary[kDisplayWeekOfManufacture] as? Int64, let kDisplayVendorID = dictionary[kDisplayVendorID] as? Int64, let kDisplayProductID = dictionary[kDisplayProductID] as? Int64, let kDisplayVerticalImageSize = dictionary[kDisplayVerticalImageSize] as? Int64, let kDisplayHorizontalImageSize = dictionary[kDisplayHorizontalImageSize] as? Int64 {
139139
struct KeyLoc {
140140
var key: String
@@ -172,7 +172,7 @@ class Arm64DDC: NSObject {
172172

173173
// Iterate to the next AppleCLCD2 or DCPAVServiceProxy item in the ioreg tree and return the name and corresponding service
174174
private static func ioregIterateToNextObjectOfInterest(interests _: [String], iterator: inout io_iterator_t) -> (name: String, service: io_service_t)? {
175-
var objectName: String = ""
175+
var objectName = ""
176176
var service: io_service_t = IO_OBJECT_NULL
177177
let name = UnsafeMutablePointer<CChar>.allocate(capacity: MemoryLayout<io_name_t>.size)
178178
defer {
@@ -236,7 +236,7 @@ class Arm64DDC: NSObject {
236236

237237
// Returns IOAVSerivces with associated display properties for matching logic
238238
private static func getIoregServicesForMatching() -> [IOregService] {
239-
var serviceLocation: Int = 0
239+
var serviceLocation = 0
240240
var ioregServicesForMatching: [IOregService] = []
241241
let ioregRoot: io_registry_entry_t = IORegistryGetRootEntry(kIOMasterPortDefault)
242242
var iterator = io_iterator_t()
@@ -273,7 +273,7 @@ class Arm64DDC: NSObject {
273273

274274
// Check if it is problematic to enable DDC on the display
275275
private static func checkIfDiscouraged(ioregService: IOregService) -> Bool {
276-
var modelIdentifier: String = ""
276+
var modelIdentifier = ""
277277
let platformExpertDevice = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice"))
278278
if let modelData = IORegistryEntryCreateCFProperty(platformExpertDevice, "model" as CFString, kCFAllocatorDefault, 0).takeRetainedValue() as? Data, let modelIdentifierCString = String(data: modelData, encoding: .utf8)?.cString(using: .utf8) {
279279
modelIdentifier = String(cString: modelIdentifierCString)

MonitorControl/Support/DisplayManager.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ class DisplayManager {
220220
func updateAudioControlTargetDisplays(deviceName: String) -> Int {
221221
self.audioControlTargetDisplays.removeAll()
222222
os_log("Detecting displays for audio control via audio device name matching...", type: .info)
223-
var numOfAddedDisplays: Int = 0
223+
var numOfAddedDisplays = 0
224224
for ddcCapableDisplay in self.getDdcCapableDisplays() {
225225
var displayAudioDeviceName = ddcCapableDisplay.readPrefAsString(key: .audioDeviceNameOverride)
226226
if displayAudioDeviceName == "" {
@@ -409,9 +409,9 @@ class DisplayManager {
409409
}
410410

411411
static func isVirtual(displayID: CGDirectDisplayID) -> Bool {
412-
var isVirtual: Bool = false
412+
var isVirtual = false
413413
if !DEBUG_MACOS10, #available(macOS 11.0, *) {
414-
if let dictionary = ((CoreDisplay_DisplayCreateInfoDictionary(displayID))?.takeRetainedValue() as NSDictionary?) {
414+
if let dictionary = (CoreDisplay_DisplayCreateInfoDictionary(displayID)?.takeRetainedValue() as NSDictionary?) {
415415
let isVirtualDevice = dictionary["kCGDisplayIsVirtualDevice"] as? Bool
416416
let displayIsAirplay = dictionary["kCGDisplayIsAirPlay"] as? Bool
417417
if isVirtualDevice ?? displayIsAirplay ?? false {
@@ -490,9 +490,9 @@ class DisplayManager {
490490
}
491491

492492
static func getDisplayRawNameByID(displayID: CGDirectDisplayID) -> String {
493-
let defaultName: String = ""
493+
let defaultName = ""
494494
if !DEBUG_MACOS10, #available(macOS 11.0, *) {
495-
if let dictionary = ((CoreDisplay_DisplayCreateInfoDictionary(displayID))?.takeRetainedValue() as NSDictionary?), let nameList = dictionary["DisplayProductName"] as? [String: String], let name = nameList["en_US"] ?? nameList.first?.value {
495+
if let dictionary = (CoreDisplay_DisplayCreateInfoDictionary(displayID)?.takeRetainedValue() as NSDictionary?), let nameList = dictionary["DisplayProductName"] as? [String: String], let name = nameList["en_US"] ?? nameList.first?.value {
496496
return name
497497
}
498498
}
@@ -505,10 +505,10 @@ class DisplayManager {
505505
static func getDisplayNameByID(displayID: CGDirectDisplayID) -> String {
506506
let defaultName: String = NSLocalizedString("Unknown", comment: "Unknown display name")
507507
if !DEBUG_MACOS10, #available(macOS 11.0, *) {
508-
if let dictionary = ((CoreDisplay_DisplayCreateInfoDictionary(displayID))?.takeRetainedValue() as NSDictionary?), let nameList = dictionary["DisplayProductName"] as? [String: String], var name = nameList[Locale.current.identifier] ?? nameList["en_US"] ?? nameList.first?.value {
508+
if let dictionary = (CoreDisplay_DisplayCreateInfoDictionary(displayID)?.takeRetainedValue() as NSDictionary?), let nameList = dictionary["DisplayProductName"] as? [String: String], var name = nameList[Locale.current.identifier] ?? nameList["en_US"] ?? nameList.first?.value {
509509
if CGDisplayIsInHWMirrorSet(displayID) != 0 || CGDisplayIsInMirrorSet(displayID) != 0 {
510510
let mirroredDisplayID = CGDisplayMirrorsDisplay(displayID)
511-
if mirroredDisplayID != 0, let dictionary = ((CoreDisplay_DisplayCreateInfoDictionary(mirroredDisplayID))?.takeRetainedValue() as NSDictionary?), let nameList = dictionary["DisplayProductName"] as? [String: String], let mirroredName = nameList[Locale.current.identifier] ?? nameList["en_US"] ?? nameList.first?.value {
511+
if mirroredDisplayID != 0, let dictionary = (CoreDisplay_DisplayCreateInfoDictionary(mirroredDisplayID)?.takeRetainedValue() as NSDictionary?), let nameList = dictionary["DisplayProductName"] as? [String: String], let mirroredName = nameList[Locale.current.identifier] ?? nameList["en_US"] ?? nameList.first?.value {
512512
name.append(" | " + mirroredName)
513513
}
514514
}

MonitorControl/Support/IntelDDC.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class IntelDDC {
3232
}
3333

3434
public func write(command: UInt8, value: UInt16, errorRecoveryWaitTime: UInt32? = nil, writeSleepTime: UInt32 = 10000, numofWriteCycles: UInt8 = 2) -> Bool {
35-
var success: Bool = false
35+
var success = false
3636
var data: [UInt8] = Array(repeating: 0, count: 7)
3737

3838
data[0] = 0x51

MonitorControl/Support/KeyboardShortcutsManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class KeyboardShortcutsManager {
113113
return
114114
}
115115
for display in affectedDisplays where !display.readPrefAsBool(key: .isDisabled) {
116-
var isAnyDisplayInSwAfterBrightnessMode: Bool = false
116+
var isAnyDisplayInSwAfterBrightnessMode = false
117117
for display in affectedDisplays where ((display as? OtherDisplay)?.isSwBrightnessNotDefault() ?? false) && !((display as? OtherDisplay)?.isSw() ?? false) && prefs.bool(forKey: PrefKey.separateCombinedScale.rawValue) {
118118
isAnyDisplayInSwAfterBrightnessMode = true
119119
}

MonitorControl/Support/MediaKeyTapManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class MediaKeyTapManager: MediaKeyTapDelegate {
113113
if isContrast, let otherDisplay = display as? OtherDisplay {
114114
otherDisplay.stepContrast(isUp: mediaKey == .brightnessUp, isSmallIncrement: isSmallIncrement)
115115
} else {
116-
var isAnyDisplayInSwAfterBrightnessMode: Bool = false
116+
var isAnyDisplayInSwAfterBrightnessMode = false
117117
for display in affectedDisplays where ((display as? OtherDisplay)?.isSwBrightnessNotDefault() ?? false) && !((display as? OtherDisplay)?.isSw() ?? false) && prefs.bool(forKey: PrefKey.separateCombinedScale.rawValue) {
118118
isAnyDisplayInSwAfterBrightnessMode = true
119119
}

MonitorControl/Support/SliderHandler.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ class SliderHandler {
222222
slider.frame.origin = NSPoint(x: 15, y: 5)
223223
let view = NSView(frame: NSRect(x: 0, y: 0, width: slider.frame.width + 30 + (showPercent ? 38 : 0), height: slider.frame.height + 14))
224224
view.frame.origin = NSPoint(x: 12, y: 0)
225-
var iconName: String = "circle.dashed"
225+
var iconName = "circle.dashed"
226226
switch command {
227227
case .audioSpeakerVolume: iconName = "speaker.wave.2.fill"
228228
case .brightness: iconName = "sun.max.fill"
@@ -361,7 +361,7 @@ class SliderHandler {
361361
var sumVal: Float = 0
362362
var maxVal: Float = 0
363363
var minVal: Float = 1
364-
var num: Int = 0
364+
var num = 0
365365
for key in self.values.keys {
366366
if let val = values[key] {
367367
sumVal += val

MonitorControl/View Controllers/Preferences/DisplaysPrefsCellView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ class DisplaysPrefsCellView: NSTableCellView {
332332
let value = sender.stringValue
333333
let values = value.components(separatedBy: ",")
334334
var normalizedValues: [String] = []
335-
var normalizedString: String = ""
335+
var normalizedString = ""
336336
for value in values {
337337
let trimmedValue = value.trimmingCharacters(in: CharacterSet(charactersIn: " "))
338338
if !trimmedValue.isEmpty, let intValue = UInt8(trimmedValue, radix: 16), intValue != 0 {

MonitorControl/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ let keyboardPrefsVc = storyboard.instantiateController(withIdentifier: "Keyboard
2828
let aboutPrefsVc = storyboard.instantiateController(withIdentifier: "AboutPrefsVC") as? AboutPrefsViewController
2929
let onboardingVc = storyboard.instantiateController(withIdentifier: "onboardingViewController") as? NSWindowController
3030

31-
autoreleasepool { () -> Void in
31+
autoreleasepool { () in
3232
let mc = NSApplication.shared
3333
let mcDelegate = AppDelegate()
3434
mc.delegate = mcDelegate

0 commit comments

Comments
 (0)