NSWorkspace.shared.icon(forFile:) does not return icon image - swift

I am working on a MacOS application where the app should show the application icons. For some app it works, for some apps it don't.
One the app for which I do not get the application icon image is the Notes.app.
let icon = NSWorkspace.shared.icon(forFile: "/Applications/Notes.app")
For Numbers.app, for example, it is loading the app icon as expected.
What is the reason behind?
I have figured out that icons are only appearing for those applications where the application has an associated filetype. Applications which do not have associations does not return the icon.
There must be a was to open an .icns file. The path to it is clearly accessible and the content of the icon file should be too.

Ok. I have figured out that some Applications are located under /System/Applications, but appears under /Applications too. This is causing the problem above.

Related

Xcode: URL Types: Icon?

The Xcode docs, explain that the CFBundleURLIconFile key contains the name of the icon image file (minus the extension) to be used for displaying URLs of this type.
My remaining questions are:
What icon image should I use? Like, if the URL type is for another app, should I use that app's app icon?
What size(s)? If many sizes, how do I name them so that the sizes are used correctly?
Where is it displayed? I'm wondering for an iPhone app.
Apple does not specify this specifically, but my interpretation is that it should be an Icon representing the application which should/will open/handle URLs of this type.
On OS X, the normal approach would be to use an Icon File (.icns). I suspect you should try that on your iOS app. If that doesn't work, duplicate the naming scheme of the the standard app icon files.
Try viewing a PDF in Safari on iOS. If you have iBooks, it should show a button saying "Open in iBooks" and shows an icon next to it. This icon is the icon you would be setting.
I hope this is thorough enough to answer your questions. If not, please explain what needs clarification.

XCode won't accept my 57x57 size icon?

I'm trying to archive my app with XCode. I have 4 different icons (57, 72, 114, 144).
It works fine when I drop them in but when I try to validate it after building I get the following...
If I go back and try to replace the 57px icon with a 72px icon I get this message.
Why is this happening?
Here is the values in plist, haven't done anything here manually.
Here is the apple doc for icons
In case the above link gets expired I'm including the screen shot, I know it's the content are impossible to see, here is the image link. Btw you can always right click on the image and copy image location and open it in new tab.
Here is how you can specify icons
In theory you can name them whatever you want for iPad as long as they are in the info.plist. In order to support older version of iOS, I always name them the way apple recommand, which has already been quoted by Inder Kumar Rathore.
Take a look at here to see how to Add Icon files in Info.plist
#PhlipK: Your info.plist looks very different from mine, here is how mine looks like.
Take a look at the link I mentioned above and try to edit your info.plist see if that works.

How do I change the text directly beneath the icon of my iphone app

There is small text beneath the icon names when you are in the home screen of the ipod.
My text is much too long and it looks like "Cedr..egg"
I was wondering if there was a way to change that text to a shorter name?
I think what you're looking for is Bundle Display Name in the info.plist file.
You can change the name of the app by renaming the app in the Applications folder in iTunes.
If you are looking to do this in Xcode you are looking for the LocalizedApplicationNames.strings file.
NOTE: This may prevent automatic upgrades in the future.

Can an iphone app change its home screen icon and name after installation?

Can an iphone app change its home screen icon and name after installation?
What i want to do is make a generic application for several of our clients, that upon installation and login by users it detects which of our client it applies to and changes its icon and name to reflect the appropriate branding.
Is this going to be possible? Or are we simply going to have to make (and submit for approval...) one app per client?
Thanks
Updated: since iOS 10 it's possible to change the application icon from the list of pre-defined ones in the Info.plist. However display name still stays the constant.
Outdated: Since app's name is in Info.plist which resides with app's icon in app's bundle (which is readonly) - it cannot. You can only change your app's name and icon after releasing an update into the appstore. You may though change application icon's badge value. But as I see in your scenario - it won't fit your needs at all.

Is it possible to change the app icon programmatically?

I want to make two different app icons, and programmatically switch betweem then. When the user quits the app without finishing an workflow-process, then I want to switch to an icon that will indicate that there's something undone when launching the app. Well, just theoretically, just for testing.
I think that the icon file is just a normal file as any other, so if I would just rename it programmatically and then give another icon file the name of the icon file that's named the Info.plist, then the app should show up with another icon, right? Would that be possible? Or do I have no access to that file for renaming it?
icon file stored in "application bundle" folder.
And your application has read-only rights to this folder
There is no oficial way to change/rename thees files.
You can add integer badge to youy icon
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:666]
But it is not official method.
It sounds like a good idea, and I would definitely give it a try, but I get the feeling this isn't possible.
I believe the app icons get stored in another file structure global to the iPhone. I say this because after I installed 3.0 beta 5, I saw a bug where the app icon disappeared from an app I developed. Then after installing two new apps from the app store, the new app's icon appeared on my app, and the 2nd new app's icon appeared on both new apps. Essentially the new app icons shifted to fill in for the missing app icon.
Removing and re-adding the apps, then rebooting the phone, restored the icons properly.
I don't know for a fact how the app icons are managed and stored on the phone, of course, but it would fit to say they are stored in some sort of cached list that gets rebuilt occasionally, perhaps after a reboot. That would mean even if you could change the icon from within your app, it would take more effort to see the effects on the phone.