Sandboxed app & record-level indexing of Core Data in Spotlight (not working)

  • I'm trying to create a spotlight importer for a core data application, using the "record level indexing" as descripted in the Core Data Spotlight Integration Programming Guide.

    I have a working .mdimporter that works correctly if I copy the importer in /Library/Spotlight (it will index and spotlight find the documents).
    The problem is that the "embedded" importer in the application (I started with the Xcode template for "use core data" and "create importer" is never called by the system. I checked that the .mdimporter is in the app bundle inside the Contents/Resources/APPNAMEImported.mdimporter directory.
    I'm planning to use MAS, so I *think* I cannot move anything in /Library/Spotlight.

    I religiously read the guide many times (and especially the "troubleshooting" section) but, you know, the more you read, the same it seems. :) Any hint on "what to look for" will be appreciated, I'm out of ideas.

    I strongly suspect that the problem is related to the sandboxing of the app, because the Guide seems to not consider sandbox. For example, I had to find by trial and error that the the NSExternalRecordsDirectoryOption for the persistent store is a tricky one for sandboxed app, at the end I use NSLibraryDirectory/CoreData/LocalConfig/ but the runtime raised exception for almost any other one, included the recommended (by the exception in itself) ~/Library/Caches/Metadata/CoreData (sandbox error) or NSCacheDirectory/Metadata/CoreData (error 'should be ~/Library/Caches/Metadata/CoreData').

    If some code is needed to troubleshoot, just ask (I really have no idea of what could be useful and not simply noise).

    Thank you in advance,
    gt
  • Date: Tue, 14 May 2013 12:07:02 +0200
    > From: Giacomo Tufano <gt...>
    > To: <cocoa-dev...>
    > Subject: Sandboxed app & record-level indexing of Core Data in
    > Spotlight (not  working)
    > Message-ID: <127DC0CB-C922-435C-ADBA-E873E8593E90...>
    > Content-Type: text/plain; charset=us-ascii
    >
    > I'm trying to create a spotlight importer for a core data application,
    > using the "record level indexing" as descripted in the Core Data Spotlight
    > Integration Programming Guide.
    >
    > I have a working .mdimporter that works correctly if I copy the importer
    > in /Library/Spotlight (it will index and spotlight find the documents).
    > The problem is that the "embedded" importer in the application (I started
    > with the Xcode template for "use core data" and "create importer" is never
    > called by the system. I checked that the .mdimporter is in the app bundle
    > inside the Contents/Resources/APPNAMEImported.mdimporter directory.
    > I'm planning to use MAS, so I *think* I cannot move anything in
    > /Library/Spotlight.
    >
    > I religiously read the guide many times (and especially the
    > "troubleshooting" section) but, you know, the more you read, the same it
    > seems. :) Any hint on "what to look for" will be appreciated, I'm out of
    > ideas.
    >
    > I strongly suspect that the problem is related to the sandboxing of the
    > app, because the Guide seems to not consider sandbox. For example, I had to
    > find by trial and error that the the NSExternalRecordsDirectoryOption for
    > the persistent store is a tricky one for sandboxed app, at the end I use
    > NSLibraryDirectory/CoreData/LocalConfig/ but the runtime raised exception
    > for almost any other one, included the recommended (by the exception in
    > itself) ~/Library/Caches/Metadata/CoreData (sandbox error) or
    > NSCacheDirectory/Metadata/CoreData (error 'should be
    > ~/Library/Caches/Metadata/CoreData').
    >
    > If some code is needed to troubleshoot, just ask (I really have no idea of
    > what could be useful and not simply noise).
    >
    > Thank you in advance,
    > gt
    >
    >
    Hi gt,

    If your importer is bundled into your app, it should be in :

    Appname.app/Contents/Library/Spotlight

    Vince.
  • Il giorno 14/mag/2013, alle ore 13:00, Vincent CARLIER <vince.carlier...> ha scritto:

    > I have a working .mdimporter that works correctly if I copy the importer in /Library/Spotlight (it will index and spotlight find the documents).
    > The problem is that the "embedded" importer in the application (I started with the Xcode template for "use core data" and "create importer" is never called by the system. I checked that the .mdimporter is in the app bundle inside the Contents/Resources/APPNAMEImported.mdimporter directory.
    > I'm planning to use MAS, so I *think* I cannot move anything in /Library/Spotlight.
    >
    > If your importer is bundled into your app, it should be in :
    > Appname.app/Contents/Library/Spotlight

    Thank you Vincent! In Contents/Library/Spotlight works. I'm wondering where's documented, but it's OK (my fault, probably).

    I now get errors (one for every file) in mdworker (apparently from sandboxing) stating:
    14/05/13 13:24:43,007 sandboxd[29551]: ([29550]) mdworker(29550) deny file-write-create /Users/gt/Library/Containers/it.iltofa.Janus/Data/Documents/SharedCoreDataStores/.localStore_SUPPORT/.LINKS (import fstype:hfs fsflag:480D000 flags:240000005F diag:0 uti:it.iltofa.janus plugin:/Janus.app/Contents/Library/Spotlight/JanusImporter.mdimporter - find suspect file using: sudo mdutil -t 17981324)
    but it seems to work (records are indexed spotlight find them, etc. (now I'll try to understand what else is wrong).

    Beside that, I'll have to understand how to convince Xcode to copy the .mdimporter in Library/Spotlight automatically (but this seems easier).

    Thank you *very* much,
    gt

    btw: a test project just created with Xcode 4.6.2 "cocoa app" template generates an .mdimporter bundled under Resources. Should I file a bug or this is expected?
  • Re gt,

    2013/5/14 Giacomo Tufano <gt...>

    > Il giorno 14/mag/2013, alle ore 13:00, Vincent CARLIER <
    > <vince.carlier...> ha scritto:
    >
    > I have a working .mdimporter that works correctly if I copy the importer
    >> in /Library/Spotlight (it will index and spotlight find the documents).
    >> The problem is that the "embedded" importer in the application (I started
    >> with the Xcode template for "use core data" and "create importer" is never
    >> called by the system. I checked that the .mdimporter is in the app bundle
    >> inside the Contents/Resources/APPNAMEImported.mdimporter directory.
    >> I'm planning to use MAS, so I *think* I cannot move anything in
    >> /Library/Spotlight.
    >>
    >
    > If your importer is bundled into your app, it should be in :
    > Appname.app/Contents/Library/Spotlight
    >
    >
    > Thank you Vincent! In Contents/Library/Spotlight works. I'm wondering
    > where's documented, but it's OK (my fault, probably).
    >
    >
    It's documented in the section "Troubleshooting Spotlight Importers", in
    Spotlight Importer Programming Guide :

    "An application’s Spotlight importer resides within the application’s
    bundle in the subdirectory MyApp.app/Contents/Library/Spotlight." (top of
    the page).

    > I now get errors (one for every file) in mdworker (apparently from
    > sandboxing) stating:
    > 14/05/13 13:24:43,007 sandboxd[29551]: ([29550]) mdworker(29550) deny
    > file-write-create /Users/gt/Library/Containers/it.iltofa.Janus/Data/Documents/SharedCoreDataStores/.localStore_SUPPORT/.LINKS
    > (import fstype:hfs fsflag:480D000 flags:240000005F diag:0
    > uti:it.iltofa.janus
    > plugin:/Janus.app/Contents/Library/Spotlight/JanusImporter.mdimporter -
    > find suspect file using: sudo mdutil -t 17981324)
    > but it seems to work (records are indexed spotlight find them, etc. (now
    > I'll try to understand what else is wrong).
    >

    Sounds like a permission problem, I never had such a problem though.

    >
    > Beside that, I'll have to understand how to convince Xcode to copy the
    > .mdimporter in Library/Spotlight automatically (but this seems easier).
    >

    Add a copy files phase in the Build Phases for the app target, select the
    "Wrapper" item in the popup button and add the subpath to the directory in
    the field below.

    > Thank you *very* much,
    > gt
    >
    > btw: a test project just created with Xcode 4.6.2 "cocoa app" template
    > generates an .mdimporter bundled under Resources. Should I file a bug or
    > this is expected?
    >
    >
    Not sure it is expected, as the documentation tells to put the importer in
    another directory. I imagine Xcode defaults to the Resources directory when
    it has to copy things.

    Vince.
previous month may 2013 next month
MTWTFSS
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    
Go to today