On iOS, we can easily use: "try await UIApplication.shared.setAlternateIconName("iconName")" to set an alternate icon.
When running the app for MacCatalyst, that method is not working, throwing the following error:
Error Domain=NSCocoaErrorDomain Code=3328 "The requested operation couldn’t be completed because the feature is not supported."
I came across this post, from which I understand I can use NSApp to set the icon.
let nsApp = Dynamic.NSApplication.sharedApplication
let newIcon = UIImage(named: "iconName"!)
nsApp.applicationIconImage = newIcon
That code works, but only temporarily (until the app is closed).
Can anybody please help? I have seen apps like Arc browser offering this functionality on the mac.
Thank you
On iOS, we can easily use: "try await UIApplication.shared.setAlternateIconName("iconName")" to set an alternate icon.
When running the app for MacCatalyst, that method is not working, throwing the following error:
Error Domain=NSCocoaErrorDomain Code=3328 "The requested operation couldn’t be completed because the feature is not supported."
I came across this post, from which I understand I can use NSApp to set the icon.
let nsApp = Dynamic.NSApplication.sharedApplication
let newIcon = UIImage(named: "iconName"!)
nsApp.applicationIconImage = newIcon
That code works, but only temporarily (until the app is closed).
Can anybody please help? I have seen apps like Arc browser offering this functionality on the mac.
Thank you
Share Improve this question asked Feb 14 at 4:49 Random playerRandom player 2321 gold badge6 silver badges16 bronze badges 1- Have you tried NSWorkspace.shared.setIcon(image, forFile: bundle.path, options: []) ? – Marek H Commented Feb 14 at 6:58
1 Answer
Reset to default 0Thank you @Marek-h for your suggestion. Using NSWorkspace.shared.setIcon(image, forFile: bundle.path, options: [])
has the same effect, only works temporarily while the app is opened.
Seems like the reason the icon keeps reverting back is because I'm running a signed app. MacOS's code signing and app sandboxing prevent permanent modifications to the app bundle, which is what I'm trying to do when setting the icon.
Seems like the only way to do this for now will be to distribute the app from outside the App Store.