-1

I'm trying to debug a crashing Finder sync extension that's part of the Nextcloud desktop client. The extension produces no crash log or useful output when it crashes, so I'm trying to figure out how to attach a debugger to it so I can see where in its source code the crash is occurring.

Nextcloud is developed using cmake, though, so I don't have an Xcode project I can use to follow the normal workflow of debugging a Finder sync extension. I tried using cmake -G Xcode to generate an Xcode project, but what it produces is, of course, a completely non-standard Xcode client with no Finder sync extension target actually in it.

Is there any way at all to debug the extension when cmake is involved?

Bri Bri
  • 2,169
  • 3
  • 19
  • 44
  • 1
    Their CMakeLists doesn't actually add the sync extension as a target. There's an Xcode project / workspace for the extension, and CMake just calls a custom command to build it. So it won't appear in your generated workspace. Could you try to add the project to the generated workspace manually? – TheNextman Feb 23 '23 at 17:25

1 Answers1

1

I did finally manage to debug the Finder extension. In this case, Nextcloud Desktop's git repo already had an Xcode project set up for this.

But the trick is to create an Xcode project with two targets, one application and one Finder extension, and then make sure that the extension is included in the application. The application can just be a shim -- the default code created by Xcode for a basic cocoa app should be fine. For the Finder extension target, though, manually set it up with the same source files and build settings as the cmake project. Give them both the same bundle ID and entitlements as the actual app being compiled by cmake. Then, follow the regular steps for debugging a Finder extension. (See the answers to this question.)

It does seem to be finicky, and sometimes I need to try several times before Xcode successfully attaches to the extension, and often I need to restart the Finder more than once. But eventually it works.

Bri Bri
  • 2,169
  • 3
  • 19
  • 44