Re: Setting app icon in NSWorkspace

2024-03-22 Thread Mark Allan via Cocoa-dev
Sorry Alex. I've done some more testing and it looks like I was mistaken. It 
*doesn't* break code signing, but it does do something odd - on any Build & Run 
from within Xcode after making that NSWorkspace API call, the codesign tool 
gives the following error message unless I clean the build folder:

> appname.app: replacing existing signature

> appname.app: resource fork, Finder information, or similar detritus not 
> allowed

If I then call `spctl -a`, it tells me 
> invalid Info.plist (plist or signature have been modified)

However, running the app, calling that API, and then running `spctl` (before 
doing another build in Xcode) it says it's fine! Subsequent runs without 
involving Xcode are problem-free.

As there's no way my users can run into this problem, I'd say everything's 
fine. I'll just add something to the precompile script to workaround it.

For what it's worth, it looks like NSWorkspace does simply mimic pasting a new 
icon in via Get Info - I can certainly clear it out from there.

Thanks and sorry for the noise.

Mark

> On 22 Mar 2024, at 2:05 pm, Alex Zavatone  wrote:
> 
> That’s a great idea.
> 
> For a Mac app, I suppose.
> 
> I wonder if a simple change in the bundle where you have the icon file be 
> symlink to a folder in the app’s documents folder and then change that file?
> 
> What if you issue a shell script to restart the Dock?  
> 
> What happens if you change the icon manually through get info?  Can you 
> duplicate your app, change the icon manually and diff the two apps to see 
> where the differences are?  Then change the icon using NSWorkspace and 
> compare the difference.
> 
> It surprises me that NSWorkspace breaks code signing.
> 
> Let me see what I can look in to.
> 
> Cheers,
> Alex Zavatone
> 
>> On Mar 22, 2024, at 8:23 AM, Mark Allan via Cocoa-dev 
>>  wrote:
>> 
>> Hi all,
>> 
>> I'm trying to offer my users the option (via a pre-defined list in my app's 
>> Preferences) to choose an app icon which shows up in the Dock and the Finder.
>> 
>> Updating the Dock tile whilst the app is running is fairly simple to 
>> achieve, but I also want the Dock icon and Finder icons to remain customised 
>> even when the app isn't running. 
>> 
>> I have the following 
>>  [[NSWorkspace sharedWorkspace] setIcon:newAppIcon forFile:[[NSBundle 
>> mainBundle] bundlePath] options:0];
>> 
>> This works, but has the unfortunate side-effect of breaking code signing!
>> 
>> Can anyone help with this please?
>> 
>> The folks at Panic have managed to do it with Nova, so it must be possible, 
>> I just can't figure it out.
>> 
>> Thanks
>> Mark
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com
>> 
>> This email sent to z...@mac.com
> 

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Setting app icon in NSWorkspace

2024-03-22 Thread Alex Zavatone via Cocoa-dev
That’s a great idea.

For a Mac app, I suppose.

I wonder if a simple change in the bundle where you have the icon file be 
symlink to a folder in the app’s documents folder and then change that file?

What if you issue a shell script to restart the Dock?  

What happens if you change the icon manually through get info?  Can you 
duplicate your app, change the icon manually and diff the two apps to see where 
the differences are?  Then change the icon using NSWorkspace and compare the 
difference.

It surprises me that NSWorkspace breaks code signing.

Let me see what I can look in to.

Cheers,
Alex Zavatone

> On Mar 22, 2024, at 8:23 AM, Mark Allan via Cocoa-dev 
>  wrote:
> 
> Hi all,
> 
> I'm trying to offer my users the option (via a pre-defined list in my app's 
> Preferences) to choose an app icon which shows up in the Dock and the Finder.
> 
> Updating the Dock tile whilst the app is running is fairly simple to achieve, 
> but I also want the Dock icon and Finder icons to remain customised even when 
> the app isn't running. 
> 
> I have the following 
>   [[NSWorkspace sharedWorkspace] setIcon:newAppIcon forFile:[[NSBundle 
> mainBundle] bundlePath] options:0];
> 
> This works, but has the unfortunate side-effect of breaking code signing!
> 
> Can anyone help with this please?
> 
> The folks at Panic have managed to do it with Nova, so it must be possible, I 
> just can't figure it out.
> 
> Thanks
> Mark
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com
> 
> This email sent to z...@mac.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Setting app icon in NSWorkspace

2024-03-22 Thread Mark Allan via Cocoa-dev
Hi all,

I'm trying to offer my users the option (via a pre-defined list in my app's 
Preferences) to choose an app icon which shows up in the Dock and the Finder.

Updating the Dock tile whilst the app is running is fairly simple to achieve, 
but I also want the Dock icon and Finder icons to remain customised even when 
the app isn't running. 

I have the following 
[[NSWorkspace sharedWorkspace] setIcon:newAppIcon forFile:[[NSBundle 
mainBundle] bundlePath] options:0];

This works, but has the unfortunate side-effect of breaking code signing!

Can anyone help with this please?

The folks at Panic have managed to do it with Nova, so it must be possible, I 
just can't figure it out.

Thanks
Mark

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com