Search code examples
macososx-elcapitanspotlight

How to add source code to Spotlight in El Capitan 10.11.1?


Developers have been using this Spotlight trick for quite some time to search their source code.

Add the file types you want to Spotlight RichText.mdimporter info.plist /System/Library/Spotlight/RichText.mdimporter

info.plist

<string>public.swift-source</string> <string>public.objective-c-source</string>

Terminal

mdimport -r /System/Library/Spotlight/RichText.mdimporter sudo mdutil -E

But access is now restricted in El Capitan. Saving the info.plist is not possible.

Anyone have a solution?


Solution

  • Boot to Recovery HD and then disable SIP in terminal.app

    csrutil disable
    

    If you want to enable all protections except a few, you can poke holes in the protection to allow debugging, dtrace, modifying filesystem restricted files, etc..

    csrutil enable -without fs
    

    See this nice answer by Rich Trouton as well as his blog for details on SIP. I can't find official Apple documentation about these options - perhaps WWDC 2016 will have new documentation on how developers can relax the default security to modify things and run custom kext, etc...

    In short - once you disable or enable without the fs restrictions, you can then edit the files needed to change the spotlight indexing rules for RichText as before.