Hello Everyone, I'm trying to add badges to files in my File Provider Extension for macOS. I'm not trying to create my own Item decorations here, but use the default Icons provided by apple (such as com.apple.icon-decoration.badge.heart , com.apple.icon-decoration.badge.pinned). I've gone through the Sample code provided by Apple for Fruit Basket.
I've tried to replicate the same thing in my Extension as well but It seems I'm unable to display Icons. I'm not even getting any Error when the Icons are not being displayed, So I've been stuck for a month on this.
These are the Things that I've done below:
Folder Structure :
FileExplorer
|- FileProviderApp
| |- UI.swift
| |- ContentView.swift
|- Extension
|- extension.swift
|- item.swift
|- enumerator.swift
|- info.plist
According to the instructions given in the Documentation for Decorations here : https://developer.apple.com/documentation/fileprovider/nsfileprovideritemdecorating. The implementation was done as follows:
content inside info.plist of the File provider Extension
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSExtension</key>
<dict>
<key>NSExtensionFileProviderSupportsEnumeration</key>
<true/>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.fileprovider-nonui</string>
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).FileProviderExtension</string>
<key>NSFileProviderDecorations</key>
<array>
<dict>
<key>BadgeImageType</key>
<string>com.apple.icon-decoration.badge.heart</string>
<key>Category</key>
<string>Badge</string>
<key>Identifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER).heart</string>
<key>Label</key>
<string>Heart Item</string>
</dict>
</array>
</dict>
</dict>
</plist>
In my extension's NSFileProviderItem I've also Implemented the protocol NSFileProviderItemDecorating
. and the decoration's method as
static let decorationPrefix = Bundle.main.bundleIdentifier!
static let heartDecoration = NSFileProviderItemDecorationIdentifier(rawValue: "\(decorationPrefix).heart")
var decorations: [NSFileProviderItemDecorationIdentifier]?
{
var decos = [NSFileProviderItemDecorationIdentifier]()
decos.append(Item.heartDecoration)
return decos
}
I was expecting to see badges on the File items in Finder, but i got nothing. When I modified the FruitBasket Project to do the same i was able to see badges, but not when I try to implement it in my Extension.
Was I missing a step or is the issue something else ?