How to add new NSFileProviderDecorations to FileProviderExtensions

I'm having an issue where adding new decorations to NSFileProviderDecorations doesn't make those decorations visible in the app.

Here is my NSFileProviderDecorations array in plist file:

<key>NSFileProviderDecorations</key>
<array>
	<dict>
		<key>BadgeImageType</key>
		<string>com.apple.icon-decoration.badge.checkmark</string>
		<key>Category</key>
		<string>Badge</string>
		<key>Identifier</key>
		<string>$(PRODUCT_BUNDLE_IDENTIFIER).iconSynced</string>
		<key>Label</key>
		<string>Synced</string>
	</dict>
	<dict>
		<key>BadgeImageType</key>
		<string>com.apple.icon-decoration.badge.warning</string>
		<key>Category</key>
		<string>Badge</string>
		<key>Identifier</key>
		<string>$(PRODUCT_BUNDLE_IDENTIFIER).iconConflict</string>
		<key>Label</key>
		<string>In Conflict</string>
	</dict>
	<dict>
		<key>BadgeImageType</key>
		<string>com.apple.icon-decoration.badge.locked</string>
		<key>Category</key>
		<string>Badge</string>
		<key>Identifier</key>
		<string>$(PRODUCT_BUNDLE_IDENTIFIER).iconLocked</string>
		<key>Label</key>
		<string>Locked</string>
	</dict>
	<dict>
		<key>BadgeImageType</key>
		<string>com.apple.icon-decoration.badge.warning</string>
		<key>Category</key>
		<string>Badge</string>
		<key>Identifier</key>
		<string>$(PRODUCT_BUNDLE_IDENTIFIER).iconUploadFailed</string>
		<key>Label</key>
		<string>Upload failed</string>
	</dict>
</array>

The first two decorations: iconSynced and iconConflict work just fine as expected, but then I added the other two decorations: iconLocked and iconUploadFailed and I just can't get them to work.

Here is an example of my decorations implementation:

var decorations: [NSFileProviderItemDecorationIdentifier]? {
    [
        entry.synced ? "iconSynced" : "",
        entry.inConflict ? "iconConflict" : "",
        entry.locked && !entry.uploadFailed ? "iconLocked" : "",
        entry.uploadFailed ? "iconUploadFailed" : ""
    ].filter { !$0.isEmpty }.map {
        NSFileProviderItemDecorationIdentifier(rawValue: "\(Bundle.main.bundleIdentifier!).\($0)")
    }
}

What I tried:

  • Clear cache project and/or manually deleting Derived Data folder
  • Various combination changes and log prints to try to figure out what's wrong
  • Increasing Xcode project version
  • Computer restart

macOS: 12.6.5 (21G531)

Does anyone have the same issue or does anyone have an idea on how to resolve this? So, my problem is that I can't get the new badge decorations added to plist file to work (to be shown in Finder when reported from decorations callback).

Accepted Reply

What helped in the end was deleting all of derived data, products and caches from both Xcode and AppCode:

  1. Delete FileProvider Main App and Extension (~/Library/Containers/MyApp, ~/Library/Containers/MyAppExtension, ~/Library/Group Containers/MyApp)
  2. Delete Xcode Derived Data (Library/Developer/Xcode/DerivedData/MyApp)
  3. Delete AppCode Derived Data (Library/Caches/JetBrains/AppCode2023.1/DerivedData/MyApp)
  4. Restart macOS
  5. Open project in Xcode, build it and run

This resulted in new decoration icons appearing properly.

Replies

What helped in the end was deleting all of derived data, products and caches from both Xcode and AppCode:

  1. Delete FileProvider Main App and Extension (~/Library/Containers/MyApp, ~/Library/Containers/MyAppExtension, ~/Library/Group Containers/MyApp)
  2. Delete Xcode Derived Data (Library/Developer/Xcode/DerivedData/MyApp)
  3. Delete AppCode Derived Data (Library/Caches/JetBrains/AppCode2023.1/DerivedData/MyApp)
  4. Restart macOS
  5. Open project in Xcode, build it and run

This resulted in new decoration icons appearing properly.