カスタム ドキュメントをインデックス化するための Spotlight プラグインを備えた、サンドボックス化された NSDocument ベースのアプリがあります。
テスト中に、Spotlight プラグインがドキュメントのインデックスを作成するときに、多くのエラーがコンソールに記録されることに気付きました。
5/4/15 3:11:18.765 PM sandboxd[432]: ([579]) mdworker(579) deny file-write-data
/Users/test/Desktop/test.document
(import fstype:hfs fsflag:480D000 flags:240000005E diag:0 isXCode:0
uti:com.test.document
plugin:/TestApp.app/Contents/Library/Spotlight/TestApp Spotlight Importer.mdimporter -
find suspect file using: sudo mdutil -t 407144)
プラグインがインデックスを作成したファイルに書き込もうとしているかのように見えます (読み取り専用アクセスしかありませんが)。
私の Spotlight プラグインの実装では、ドキュメントに書き込むために特に何もしません。NSDocument サブクラスを初期化してドキュメントから読み取るだけです。
[[TTCustomDocument alloc] initWithContentsOfURL:url ofType:contentType error:outError];
スタック トレースは次のとおりです。
Thread 4:
0 libsystem_kernel.dylib 0x00007fff9015ee92 __mac_syscall + 10
1 libsystem_sandbox.dylib 0x00007fff910140b0 sandbox_check + 206
2 AppKit 0x00007fff8f75fc38 -[NSDocument _autosavingPossibilityConcern] + 213
3 AppKit 0x00007fff8f75fb02 -[NSDocument _checkAutosavingPossibilityAndReturnError:] + 60
4 AppKit 0x00007fff8f75f9cf -[NSDocument _checkAutosavingAndReturnError:] + 26
5 AppKit 0x00007fff8f75f97e -[NSDocument _checkAutosavingAndUpdateLockedState] + 26
6 AppKit 0x00007fff8f75e420 -[NSDocument _initWithContentsOfURL:ofType:error:] + 319
7 AppKit 0x00007fff8f75e056 -[NSDocument initWithContentsOfURL:ofType:error:] + 230
自動保存チェックがどういうわけかドキュメントに書き込もうとしているようです。
これについて私にできることはありますか?NSDocument を開くための読み取り専用モードはありますか?
アップデート:
再現するには:
- 新しい Xcode プロジェクトを作成します: 「Cocoa ドキュメント ベースのアプリ」
- Spotlight プラグインを追加する
- NSDocument 実装と Spotlight プラグインのコードはこちら: https://gist.github.com/anonymous/c4929586dfa11a473673