Post

Replies

Boosts

Views

Activity

Programatically changing the brightness of your Macbook
Hi all, I was wondering if anyone knew a way to change the brightness of your MacBook screen in Swift without using an overlay that changes the colours? I want the effect of just pressing the F1 and F2 brightness controls but done without using system events/ Applescript popping up windows on the screen. I think the UIScreen.brightness is something similar to what I want but it is not available for NSscreen. I can't figure out a way to do it with IOKit either. Things like ddccl doesn't work as the screen is not an external monitor. If there is a solution using Swift or terminal commands any help is much appreciated. Thanks, James
1
0
363
Aug ’24
Setting Display Colour Profiles via terminal
Hi, I'm looking at being able to set a display colour profile via terminal. I know apps such as SwitchResX are able to change this but i can't figure out how and if it is possible to switch via a terminal command or via a script. This here is what i would like to change. I have googled about and searched through preference files but can't find anything. Any help is much apreciated. Thanks, James
0
0
445
May ’24
App Crashing on any Mac that hasn't run the app in XCode Debug mode.
Hi all, I am creating an app that includes a sandboxed FinderSync extension and an unsandboxed main app. The app runs fine when running it from xcode and also on any Mac that has ever run it from XCode but whenever I put the app on a clean Mac that has not run the app in XCode it crashes seconds after I trigger a function in my finder sync extension. I think that the error occurs around here FindeSync.swift func showWindow(with context: NSExtensionContext) { NSLog("hello") let center: DistributedNotificationCenter = DistributedNotificationCenter.default() print("1") let notificationName = NSNotification.Name("com.jdoglobal.JDOShare.displayWindow") print("2") center.postNotificationName(notificationName, object: nil, deliverImmediately: true) print("3") } as "hello" is printed to the console but "1", "2", or "3" are never printed but the notification is received as you can see the window pop up briefly before crashing. AppDelegate.Swift func applicationDidFinishLaunching(_ aNotification: Notification) { DistributedNotificationCenter.default().addObserver(self, selector: #selector(displayWindow), name: Notification.Name("com.jdoglobal.JDOShare.displayWindow"), object: nil) Here is my crash report from the clean Mac: JDO-Share-2023-06-15-163212.txt Here is all console logs for lifespan of the app. default 15:51:55.753371+0100 JDO-Share Received configuration update from daemon (initial) default 15:51:55.754173+0100 JDO-Share CHECKIN: pid=2053 default 15:51:55.762979+0100 JDO-Share CHECKEDIN: pid=2053 asn=0x0-0x10d10d foreground=0 default 15:51:55.764550+0100 JDO-Share FRONTLOGGING: version 1 default 15:51:55.764568+0100 JDO-Share Registered, pid=2053 ASN=0x0,0x10d10d default 15:51:55.766695+0100 JDO-Share BringForward: pid=2053 asn=0x0-0x10d10d bringForward=0 foreground=0 uiElement=1 launchedByLS=1 modifiersCount=1 allDisabled=0 default 15:51:55.766968+0100 JDO-Share BringFrontModifier: pid=2053 asn=0x0-0x10d10d Modifier 0 hideAfter=0 hideOthers=0 dontMakeFrontmost=0 mouseDown=0/0 seed=0/0 default 15:51:55.767899+0100 JDO-Share Current system appearance, (HLTB: 2), (SLS: 1) default 15:51:55.769399+0100 JDO-Share No persisted cache on this platform. default 15:51:55.771110+0100 JDO-Share Post-registration system appearance: (HLTB: 2) default 15:51:55.806716+0100 JDO-Share Registering for test daemon availability notify post. default 15:51:55.806859+0100 JDO-Share notify_get_state check indicated test daemon not ready. default 15:51:55.806950+0100 JDO-Share notify_get_state check indicated test daemon not ready. default 15:51:55.807043+0100 JDO-Share notify_get_state check indicated test daemon not ready. default 15:51:55.810609+0100 JDO-Share SignalReady: pid=2053 asn=0x0-0x10d10d default 15:51:55.811420+0100 JDO-Share SIGNAL: pid=2053 asn=0x0x-0x10d10d error 15:51:55.826136+0100 JDO-Share Couldnt read values in CFPrefsPlistSource<0x600003636780> (Domain: group.XXXXXX.com.jdoglobal.JDOShare, User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null), Contents Need Refresh: Yes): Using kCFPreferencesAnyUser with a container is only allowed for System Containers, detaching from cfprefsd default 15:52:06.743503+0100 JDO-Share LSExceptions shared instance invalidated for timeout. default 15:52:33.533476+0100 RightClick hello default 15:52:33.551801+0100 JDO-Share NSApp cache appearance: -NSRequiresAquaSystemAppearance: 0 -appearance: (null) -effectiveAppearance: <NSCompositeAppearance: 0x600003604a80 ( "<NSDarkAquaAppearance: 0x60000361c680>", "<NSSystemAppearance: 0x60000361a880>" )> error 15:52:33.578002+0100 JDO-Share cannot open file at line 45530 of [9ff244ce07] error 15:52:33.578033+0100 JDO-Share os_unix.c:45530: (2) open(/var/db/DetachedSignatures) - No such file or directory default 15:52:33.583056+0100 JDO-Share TrustSettingsUseXPC is enabled (via feature flags) default 15:52:33.586821+0100 JDO-Share SetFrontProcess: asn=0x0-0x10d10d options=1 default 15:52:33.840691+0100 JDO-Share Not internal release, disabling SIRL default 15:52:33.840879+0100 JDO-Share Adding securityd connection to pool, total now 1 default 15:52:33.848897+0100 JDO-Share -[SOConfigurationClient init] on <private> default 15:52:33.849334+0100 JDO-Share <SOServiceConnection: 0x600001853280>: new XPC connection I am getting really confused as to why the app works completely fine on my Mac and not on a clean Mac so if anyone could shed any light on this it would be great. For extra context: The app leads on to use Microsoft's MSAL library which I am unsure if this is having any affect on it. I have double checked the app groups in the developer portal and on each target in the app. The app works across both intel and M1 if being run/ has been run from xcode. and crashes across multiple versions of Ventura and Monterey and chips if not been run. I Get the "Distributed" app by Archiving > Distribute App > Developer ID > Export > Automatically Manage Signing > Then save. I have tried a few different variations of this but I've found this the best way as I'm not releasing on the App store Again it works perfectly fine on my Mac after I have made sure I have shut down any debugging processes happening and it is purely the distributed app running. As a side note I have followed loads of tutorials on how to set up shared defaults between an app and it's extension and it seems to work but I can't get rid of this error. error 15:51:55.826136+0100 JDO-Share Couldnt read values in CFPrefsPlistSource<0x600003636780> (Domain: group.XXXXXX.com.jdoglobal.JDOShare, User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null), Contents Need Refresh: Yes): Using kCFPreferencesAnyUser with a container is only allowed for System Containers, detaching from cfprefsd Is it worth worrying about or can I just leave it? Any help/ code improvements are greatly appreciated thanks :)
2
1
1.5k
Jun ’23
Giving my app read access to the Desktop/ Documents of the current user
I would like to give Desktop Access to my app using this pop up on launch for the first time exactly like Bridge does. Do I need Privileged File Operation entitlement or is there a way to get around this without paying to become an apple developer? I'm not planning on releasing my app on the Mac app store but it does need to be sandboxed due to using finder sync. func applicationDidFinishLaunching(_ aNotification: Notification) { let url = URL(fileURLWithPath: "/Users/useraccount/Desktop/", isDirectory: true) let configuration: NSWorkspace.OpenConfiguration = NSWorkspace.OpenConfiguration() configuration.promptsUserIfNeeded = true let finder = NSWorkspace.shared.urlForApplication(withBundleIdentifier: "com.apple.finder") NSWorkspace.shared.open([url], withApplicationAt: finder!, configuration: configuration) } This code only makes this pop up appear Any help much appreciated.
5
1
1.1k
May ’23
Swift InputStream.hasBytesAvailable() returns false when reading a file on the desktop in swift how do I fix this?
I'm creating a Swift finder sync extension that needs to read the file data into an array to send to an api but it won't read it into the array because InputStream.hasBytesAvailable() returns false so won't enter the for loop. my app requires the app sandbox which iv'e got "User Selected Files" and "Downloads" folder given read/ write access. I've also given the app full disk access in my system settings. This is my block of code causing the error specifically at the start of the While loop. let filePath = "/Users/<user>/Desktop/film.mp4" guard let inputStream = InputStream(fileAtPath: filePath) else { print("Failed to create input stream") return } // This dictates how many bytes are in each packet it must be a multiple of 327,680 let packetSize = 3276800 inputStream.open() var buffer = [UInt8](repeating: 0, count: packetSize) // Write data to bytesArray while inputStream.hasBytesAvailable{ let bytesRead = inputStream.read(&buffer, maxLength: buffer.count) if bytesRead < 0 { print("Failed to read from input stream: \(inputStream.streamError?.localizedDescription ?? "unknown error")") break } else if bytesRead == 0 { print("End of input stream reached") break } else { // Process the bytes that were read let data = Data(bytes: buffer, count: bytesRead) bytesArray.append(data) } } inputStream.close() these errors are printed in the console when i hit the button: open flag(s) 0x01000000 are reserved for VFS use and do not affect behaviour when passed to sqlite3_open_v2 cannot open file at line 46922 of [554764a6e7] os_unix.c:46922: (0) open(/private/var/db/DetachedSignatures) - Undefined error: 0 I have tried deleting the the app sandbox which can stop access to some files but when my app builds it doesn't run properly and my option doesn't appear in the context menu and no setup logs are printed to the console. It works in my first app that doesn't have an app sandbox and isn't split over two targets. Any help is much appreciated
6
1
1.7k
May ’23