Hi all,
I have found a solution that works well.
If you create a shortcut on your Mac like this.
then you can run it as a terminal command from swift like this.
func setLaptopBrightness(brightness: Float){
let command = "shortcuts run 'Set Laptop Brightness' <<< \(brightness)"
let _ = shell(command)
}
or directly from terminal like this
shortcuts run 'Set Laptop Brightness' <<< 0.5
It works well for controlling your MacBook brightness programmatically until Apple lets us do it directly via Swift.
Thanks,
James
Post
Replies
Boosts
Views
Activity
Amazing thanks, fixed the issue.
I used
atos -o /Applications/JDO-Share\ DY\ 3/JDO-Share.app/Contents/MacOS/JDO-Share -l 0x106b6b000 0x106b779f8
in the terminal to decode on the machine that the app crashed on and found that I was not handling if an account being passed into a function later on in the code was nil.
Running it on the machine that crashed I think was the key otherwise atos didn't seem to work and just returned the memory address.
I also made sure I was signing the app with a Developer Apple ID provisioning profile and a Developer ID application certificate and switched print to os_log.
Thanks!
Hi Eskimo, I am currently signing my code with my Apple ID and I believe an Apple Development Certificate is this the correct form of a stable signing identity? I'll give it a go running my code on a clean machine, but unfortunatley using tccutil didn't work.
Ok, so to clarify.
I need to add a temporary entitlement to disable the sandbox restriction.
And then I need to get a Developer ID signing identity to remember the answer to the MAC check.
However I do not need to have a Developer ID signing identity to prompt the MAC check?
From what I understand I should be getting a MAC check even if it doesn't remember my answer, but I am not when trying to access the desktop.
How do i get this pop up to show up to show when i run the app for the first time?
“AAA” would like to access files in your Desktop folder.
[Don’t Allow] [OK]
In your thread it makes it seem like it should just appear when the application tries to access a file on the desktop but is there anything else i need to do to get this popup to appear?
Again thanks for the help :)
Thanks for the reply @eskimo!
So if I use NSOpenPanel() in my finder sync file and the user selects the home folder, will that give my app access to all sub folders and files and they won't have to give that permission again? Would you say this is a better approach than trying to use a temporary exception entitlements? I don't plan on shipping the app on the Mac App Store.
Also thanks for the notice about InputStream.
This is what i'm trying to use now but it just produces a very buggy and unusable window and I can't get the window to show when running it in override func beginObservingDirectory(at url: URL) {}
class FinderSync: FIFinderSync {
override init() {
super.init()
// Check if there is a previously selected folder URL
let defaults = UserDefaults.standard
guard let selectedFolderURL = defaults.url(forKey: "selectedFolderURL") else {
// Show the NSOpenPanel to select a folder
let openPanel = NSOpenPanel()
openPanel.canChooseDirectories = true
openPanel.canChooseFiles = false
openPanel.allowsMultipleSelection = false
openPanel.prompt = "Select a folder"
if openPanel.runModal() == .OK, let url = openPanel.urls.first {
// Store the selected folder URL
defaults.set(url, forKey: "selectedFolderURL")
}
return
}
}
Thanks for your help.
I think I may need to add com.apple.security.temporary-exception.files.home-relative-path.read-only to my .extensions file to let my app be able to access my home folder. It is a finder sync extension so needs to be sandboxed and this looks like the way to get around it.
Does anyone know if this is correct?
Thanks