カスタムキーボードエクステンションからファイルが読み込めない
上記を参考にしていますが・・・

print(realmPath)

では

/private/var/mobile/Containers/Shared/AppGroup/****-****--****/test.realm  

となりますが・・・

let realm = try! Realm(path: realmPath)

のところで、

2015-10-16 08:58:46.720 Test-Keyboard[8880:557651] ***storageTaskManagerExistsWithIdentifier:withIdentifier failed: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.nsurlstorage-cache was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.nsurlstorage-cache was invalidated.}; {
NSDebugDescription = "The connection to service named com.apple.nsurlstorage-cache was invalidated.";}
fatal error: 'try!' expression unexpectedly raised an error: Error Domain=io.realm Code=1 "open() failed: Operation not permitted" UserInfo={NSLocalizedDescription=open() failed: Operation not permitted, Error Code=1}: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-700.0.59/src/swift/stdlib/public/core/ErrorType.swift, line 50
(lldb) 

というエラーが出てしまいます。

データベースファイルを共有エリアにコピーとかが必要なのか?
でも、それもgoogleで探していますが、方法がわかりません。

ソースは下記の通りです。

どうか改善策を、教えていただけないでしょうか?
よろしくお願いいたします。

import UIKit
import RealmSwift
import Foundation

class dic: Object {
    dynamic var ID = 0
    dynamic var yomi = ""
    dynamic var emoji = ""
    dynamic var date = NSDate(timeIntervalSince1970: 1)

    override static func primaryKey() -> String? {
        return "ID"
    }
}



class KeyboardViewController: UIInputViewController {

    @IBOutlet var nextKeyboardButton: UIButton!
    var button11: UIButton!
    var button12: UIButton!
    var fFastBoot = true
    var fPri = CGFloat(20)
    var ifontSize = 18.0
    var RPath = ""

    // Portrait表示におけるキーボードの高さ
    private var portraitHeight: CGFloat = 190.0
    private var portraitWidth: CGFloat!

    // Landscape表示におけるキーボードの高さ
    private var landscapeHeight: CGFloat = 100.0
    private var landscapeWidth: CGFloat!

    override func updateViewConstraints() {
        super.updateViewConstraints()

    }


    var realmPath: String {
        let containerURL = NSFileManager().containerURLForSecurityApplicationGroupIdentifier("group.AppGrouptestKeybora")
        return containerURL!.URLByAppendingPathComponent("test.realm").path!
    }


    override func viewDidLoad() {
        super.viewDidLoad()

        // Perform custom UI setup here

        ・・・

        let inputText = "か"
        print("test1")  
        print(realmPath)
        realm = try! Realm(path: realmPath)  //ここでエラー
        print("test1.5")
        let results = realm.objects(dic)
            .filter("yomi BEGINSWITH %@", inputText)
            .sorted("date", ascending: false)
        print("test2")


        for result in results {
            print(result)
        }
        print("test3")
    }
・・・

こんなのも、関係あるでしょうか?

func createPath() -> String {

    let docsPath = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.LibraryDirectory , NSSearchPathDomainMask.UserDomainMask, true)[0]
    let databaseStr = "test.realm"
    let dbPath = docsPath.stringByAppendingString(databaseStr)

    // BEGING MODIFICATION
    let fileMan = NSFileManager.defaultManager()
    if !(fileMan.fileExistsAtPath(dbPath)) {    // The database does not already exist in Documents directory
        if let source = NSBundle.mainBundle().resourcePath?.stringByAppendingString(databaseStr) {
            if !(fileMan.fileExistsAtPath(source)) {
                print("RealmDB - file \(databaseStr) not found in bundle")
            } else {
                do {
                    try fileMan.copyItemAtPath(source, toPath: dbPath)
                } catch let error as NSError {
                    print("RealmDB - failed to copy writable version of DB!")
                    print("Error - \(error.localizedDescription)")
                }
            }
        }
    }
    // END MODIFICATION

    return dbPath
}