xcodemacosspotlightsymbolicate

How can I tell Spotlight to index my .dSYM bundles?


Today was the first time that I tried - and failed - to symbolicate a crash log on a newly bought MacBook (let's call this machine MB1). MB1 came with Mac OS X 10.9 pre-installed. I tracked the problem of the failing symbolication down to Spotlight not indexing any of my .dSYM bundles (without the Spotlight index, Apple's symbolicatecrash script fails to locate the .dSYM bundle that matches the crash log). I came to my conclusion because

mdfind "com_apple_xcode_dsym_uuids == *"

does not print anything, although I have several .xcarchive bundles in my ~/Library/Developer/Xcode/Archives folder, and they definitely contain .dSYM sub-bundles whose UUID I can print with dwarfdump --uuid. I also have a couple of .dSYM bundles inside my project's build folder (DerivedData), but none of them are indexed either.

The short and easy question therefore is: How can I tell Spotlight to index my .dSYM bundles?


In case there is no easy answer for this easy question, here is what I have already tried on MB1:


To go into more detail: I have an older MacBook (let's call this machine MB2) that was my dev machine before I switched to MB1. On MB2 I never had any trouble with symbolicating. MB2 had Mac OS X 10.8 installed while I was still actively developing on it, but I recently upgraded MB2 to Mac OS X 10.9.

Today, running mdfind on MB2 still gives me a lot of .dSYM bundles, both from the Archives folder and from the project's DerivedData build folder. These are all old files from the Mac OS X 10.8 days, but apparently Spotlight keeps its index across OS upgrades. I thought it would be interesting to see how Spotlight behaves when new files are created, so I did the following:

  1. Fire up Xcode on MB2, create a new archive, and run mdfind. This finds the intermediate .dSYM bundle inside the DerivedData build folder.
  2. Delete the intermediate .dSYM bundle and run mdfind again. No results this time, i.e. the .dSYM bundle inside the Archives folder is NOT found!
  3. Make a copy of the .xcarchive bundle created in step 1 and place the copy in the root of the user home directory. Run mdfind. This finds the .dSYM sub-bundle within the copied .xcarchive bundle!

At this point, I jumped to the conclusion that because ~/Library is a hidden folder this is what prevents Spotlight from indexing stuff within it. This can be easily confirmed by creating a regular file inside ~/Library and searching for it (no hits), then moving the file outside of ~/Library and searching again (1 hit). Unfortunately, this theory falls flat on its nose because of two reasons:


Back to MB1: I tried to repeat step 3 from above, i.e. make a copy of the .xcarchive bundle in the root of the user's home directory, then run mdfind. Surprisingly, on MB1, the result is different from MB2: mdfind still finds no .dSYM bundles whatsoever!


At this point I give up and hope for your help. My conclusion is that Mac OS X 10.9 is somehow responsible for my problems, but for the life of me I can't figure out why this is so. In case it helps, here are a few additional configuration details:


Solution

  • Peeking into an Xcode application bundle reveals the following Spotlight importers:

    caradhras:~ --> find /Applications/Xcode-5.0.2.app -name \*.mdimporter
    /Applications/Xcode-5.0.2.app/Contents/Applications/Application Loader.app/Contents/Library/Spotlight/MZSpotlight.mdimporter
    /Applications/Xcode-5.0.2.app/Contents/Library/Spotlight/uuid.mdimporter
    

    Running this command

    mdimport -g /Applications/Xcode-5.0.2.app/Contents/Library/Spotlight/uuid.mdimporter ~
    

    finally indexes the .xcarchive bundle that is in the root of the user's home directory. It does NOT index the bundles in ~/Library/Developer/Xcode/Archives, though, even when I explicitly point mdimport to this folder.

    The question remains: Why is uuid.mdimporter not run automatically?


    EDIT

    The solution was to reboot the machine (logout/login might have been sufficient), archive bundles outside of ~/Library are now properly indexed. The reason why I needed to reboot probably is this:

    Anyway, during troubleshooting I found that you can check the list of active Spotlight importers by running mdimport -L (note that different users can have different Spotlight importers active at the same time). Unsurprisingly, after the reboot uuid.mdimporter is now listed, while before the reboot it was not.

    Here is a useful Apple document that I found after some googling: Troubleshooting Spotlight Importers.


    FINAL SOLUTION

    Configure Xcode so that the archive folder is located outside of ~/Library. In Xcode 6 you can do this in the Preferences dialog, under the "Locations" tab.