|
| 1 | +<!-- |
| 2 | + - SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors |
| 3 | + - SPDX-License-Identifier: GPL-2.0-or-later |
| 4 | +--> |
| 5 | + |
| 6 | +# macOS Finder Integration (FinderSync) Extension |
| 7 | + |
| 8 | +## Overview |
| 9 | + |
| 10 | +The Finder integration — the Nextcloud context-menu entries and the sync-status |
| 11 | +icons (badges) shown for folders under Finder's **Favorites** — is provided by a |
| 12 | +separate macOS app extension, `FinderSyncExt` (bundle identifier |
| 13 | +`com.nextcloud.desktopclient.FinderSyncExt` for the official build). It is |
| 14 | +distinct from the File Provider extension (`FileProviderExt`), which drives the |
| 15 | +**Locations** integration for virtual files. macOS allows only one of the two to |
| 16 | +be active at a time, by design. |
| 17 | + |
| 18 | +For the integration to work, three things must happen: |
| 19 | + |
| 20 | +1. **Registration** — macOS (LaunchServices / PlugInKit, `pluginkit`) must |
| 21 | + discover and elect the extension for the logged-in user. |
| 22 | +2. **Enablement** — the user must have it enabled (this is the state a `+` in |
| 23 | + `pluginkit -m` reflects). |
| 24 | +3. **Connection** — the extension process, launched by Finder, must connect back |
| 25 | + to the running desktop client over XPC and complete a handshake. |
| 26 | + |
| 27 | +Historically the integration appeared "not loaded" (missing badges/menus after a |
| 28 | +reboot) even when steps 1 and 2 were fine, because step 3 could silently fail — |
| 29 | +see [#10032](https://github.com/nextcloud/desktop/issues/10032), |
| 30 | +[#8471](https://github.com/nextcloud/desktop/issues/8471) and |
| 31 | +[#8363](https://github.com/nextcloud/desktop/issues/8363). The extension now only |
| 32 | +reports itself connected after a real XPC **handshake** round-trip with the |
| 33 | +client succeeds, and both the installer and the runtime log every outcome so a |
| 34 | +failure is recognizable from logs alone. This document explains how to read them. |
| 35 | + |
| 36 | +## Verifying installation |
| 37 | + |
| 38 | +The installer's postinstall script ([`admin/osx/post_install.sh.cmake`](../admin/osx/post_install.sh.cmake)) |
| 39 | +registers and enables the extension **for the logged-in console user** |
| 40 | +(`pluginkit` state is per-user, and the script itself runs as `root`, so it hops |
| 41 | +into the user's context with `launchctl asuser` + `sudo -u`). Every step is |
| 42 | +logged to `/var/log/install.log` with the prefix `Nextcloud FinderSync:`. |
| 43 | + |
| 44 | +```console |
| 45 | +grep "Nextcloud FinderSync" /var/log/install.log |
| 46 | +``` |
| 47 | + |
| 48 | +A healthy installation ends with: |
| 49 | + |
| 50 | +``` |
| 51 | +Nextcloud FinderSync: pluginkit -e use succeeded for com.nextcloud.desktopclient.FinderSyncExt |
| 52 | +Nextcloud FinderSync: extension present in pluginkit database after registration (see line above for election state) |
| 53 | +``` |
| 54 | + |
| 55 | +Signals that registration did **not** happen: |
| 56 | + |
| 57 | +| Log line | Meaning | |
| 58 | +| --- | --- | |
| 59 | +| `WARNING pluginkit -a failed …` / `WARNING pluginkit -e use failed …` | The registration/election command returned non-zero. | |
| 60 | +| `WARNING extension NOT present in pluginkit database after registration …` | The extension is still not registered after the attempt. | |
| 61 | +| `no console user logged in; skipping pluginkit registration …` | Installed with no GUI user (e.g. MDM/remote). The extension is expected to register on the user's first launch of the app instead. | |
| 62 | +| `pluginkit not found; cannot register extension …` | `pluginkit` is unavailable on this system. | |
| 63 | + |
| 64 | +## Verifying at runtime |
| 65 | + |
| 66 | +### Is the extension registered and enabled? |
| 67 | + |
| 68 | +```console |
| 69 | +pluginkit -mvvv -i com.nextcloud.desktopclient.FinderSyncExt |
| 70 | +``` |
| 71 | + |
| 72 | +A leading `+` means enabled, `-` means installed but disabled, `?` means |
| 73 | +registered without an explicit election, and empty output means it is not |
| 74 | +registered at all. |
| 75 | + |
| 76 | +### Does the extension reach the client? (the handshake) |
| 77 | + |
| 78 | +The extension logs its connection lifecycle to the unified system log under its |
| 79 | +own bundle identifier as subsystem. Watch it live while the client starts (or |
| 80 | +right after logging in): |
| 81 | + |
| 82 | +```console |
| 83 | +log stream --level info --predicate 'subsystem == "com.nextcloud.desktopclient.FinderSyncExt"' |
| 84 | +``` |
| 85 | + |
| 86 | +Or inspect what already happened (info-level entries are not persisted forever, |
| 87 | +so keep the window short): |
| 88 | + |
| 89 | +```console |
| 90 | +log show --last 10m --info --predicate 'subsystem == "com.nextcloud.desktopclient.FinderSyncExt"' |
| 91 | +``` |
| 92 | + |
| 93 | +Key messages and what they mean: |
| 94 | + |
| 95 | +| Message | Level | Meaning | |
| 96 | +| --- | --- | --- | |
| 97 | +| `FinderSync XPC handshake succeeded; connection to app is live` | info | **Working.** The extension confirmed the client is on the other end. | |
| 98 | +| `Performing XPC handshake with app (generation N)` | info | A connection attempt is in progress. | |
| 99 | +| `FinderSync XPC handshake timed out after 5 s` | error | The client was reachable but did not answer the handshake. A reconnect is scheduled. | |
| 100 | +| `FinderSync XPC message to app failed: …` | error | The client is not listening yet (e.g. extension started before the app). A reconnect is scheduled. | |
| 101 | +| `FinderSync XPC connection lost (<reason>); scheduling reconnect` | error | An established connection dropped (client quit, interrupted, …). | |
| 102 | +| `Scheduling reconnect in N seconds` | info | Backoff between retries (1 → 2 → 4 → 8 s). | |
| 103 | + |
| 104 | +Transient failures immediately after login are normal: the extension is |
| 105 | +typically launched by Finder before the client finishes starting, so you may see |
| 106 | +a `message to app failed` / reconnect or two followed by `handshake succeeded`. |
| 107 | +What indicates a real problem is `handshake succeeded` **never** appearing, or a |
| 108 | +previously-live connection producing repeated `connection lost` entries. |
| 109 | + |
| 110 | +The client side of the same handshake is logged in the **desktop client log** |
| 111 | +(not the system log), at info level under the categories |
| 112 | +`nextcloud.gui.macos.findersync.xpc` and `nextcloud.gui.macfindersyncservice`. |
| 113 | +The positive confirmation there is: |
| 114 | + |
| 115 | +``` |
| 116 | +FinderSync extension handshake received; connection to app is live |
| 117 | +``` |
| 118 | + |
| 119 | +## Remediation |
| 120 | + |
| 121 | +If the extension is registered and enabled (`+` above) but never completes the |
| 122 | +handshake, and the client is definitely running: |
| 123 | + |
| 124 | +1. Disable and re-enable **Nextcloud** in **System Settings** under **Login Items |
| 125 | + & Extensions** (on older macOS: **Privacy & Security ▸ Extensions**). |
| 126 | +2. Relaunch Finder (`killall Finder`). |
| 127 | + |
| 128 | +These are workarounds for a stuck state, not a fix. When reporting a problem, |
| 129 | +attach the output of the `grep`, `pluginkit -m` and `log show` commands above. |
| 130 | + |
| 131 | +## Implementation references |
| 132 | + |
| 133 | +- Extension XPC client and handshake / reconnect logic: |
| 134 | + [`shell_integration/MacOSX/NextcloudIntegration/FinderSyncExt/FinderSyncXPCManager.m`](../shell_integration/MacOSX/NextcloudIntegration/FinderSyncExt/FinderSyncXPCManager.m) |
| 135 | +- Extension principal object (badges, menus, bounded menu wait): |
| 136 | + [`shell_integration/MacOSX/NextcloudIntegration/FinderSyncExt/FinderSync.m`](../shell_integration/MacOSX/NextcloudIntegration/FinderSyncExt/FinderSync.m) |
| 137 | +- Shared XPC protocol (`performHandshakeWithReply:`): |
| 138 | + [`shell_integration/MacOSX/NextcloudIntegration/FinderSyncExt/Services/FinderSyncAppProtocol.h`](../shell_integration/MacOSX/NextcloudIntegration/FinderSyncExt/Services/FinderSyncAppProtocol.h) |
| 139 | +- Client-side XPC listener and service: |
| 140 | + [`src/gui/macOS/findersyncxpc_mac.mm`](../src/gui/macOS/findersyncxpc_mac.mm), |
| 141 | + [`src/gui/macOS/findersyncservice.mm`](../src/gui/macOS/findersyncservice.mm) |
| 142 | +- Installer registration: |
| 143 | + [`admin/osx/post_install.sh.cmake`](../admin/osx/post_install.sh.cmake) |
0 commit comments