Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS: use native Spotlight #1808

Open
MaddTheSane opened this issue Dec 8, 2024 · 4 comments
Open

macOS: use native Spotlight #1808

MaddTheSane opened this issue Dec 8, 2024 · 4 comments

Comments

@MaddTheSane
Copy link

Since 10.4, macOS has had a powerful search engine called Spotlight. It should be possible for Netatalk, if ran on a macOS computer, to hook into the built-in search service. This would remove the need to set-up a separate search tracker on Macs to get search working.

@rdmark
Copy link
Member

rdmark commented Dec 8, 2024

I assume you mean the Core Spotlight API[1] ? Glancing through the documentation, the API allows for indexing files so it should be feasible, at a high level.

There are a few fundamental technical challenges to solve off the bat:

  • Netatalk is pure C, while the Core Spotlight API is Objective-C. Shall the Spotlight implementation be mixed C and ObjC, or a separate Obj-C library that afpd is linked with?
  • Can Meson build mixed C and ObjC projects? Can the Ninja build backend build mixed C and ObjC code, or do we have to add Xcode build backend support to the build system?
  • Is the Core Spotlight API fork safe? The netatalk daemons use forking liberally, which Apple officially do not allow in Objective-C code, but works under some circumstances. [2] (We recently stopped linking with Apple's LDAP framework to get away from this problem.)

[1] https://developer.apple.com/documentation/corespotlight?language=objc
[2] https://developer.apple.com/forums/thread/737464?answerId=764686022#764686022

@NJRoadfan
Copy link
Contributor

Objective-C is an extension to C. The two can be mixed without too much issue (C++ on the other hand....). Forking shouldn't be an issue if you isolate the interface to a separate process (this can keep the Netatalk side as C as well, just wrap the Obj-C calls in that separate helper process).

Meson shouldn't have a problem with Objective-C. All the major compiler suites support it as well.

@MaddTheSane
Copy link
Author

There's a C-based API in CoreServices called SearchKit.

@rdmark
Copy link
Member

rdmark commented Dec 9, 2024

Search Kit seems like the more appropriate API to use for this purpose.

The Search Kit API is appropriate when you want your application to have full control over indexing and searching, and when your focus is file content. Search Kit is thread-safe and works with Cocoa, Carbon, and command-line tools.

https://developer.apple.com/documentation/coreservices/search_kit?language=objc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants