SQlite Cipher IOS

时间:2016-10-05 07:38:52

标签: ios swift ipad sqlite

This here i have shared to show that i have Sqlite file present in copy bundle resources : 我在iOS应用中使用Sqlitecipher在Simulator(离线)中运行我的应用时,它会成功显示所有数据,并且每个查询都能正常工作,如(更新,删除,插入),但在设备上测试我的应用时,它并没有显示任何内容。按照我试过的方式:

  1. 已保存Sqlite个文件包
  2. 将包中的Sqlite文件复制到Document Directory
  3. Simulator删除应用并重置我的Simulator,但我仍面临同样的问题。请建议解决方案( Salesforce本地应用程序
  4. 这是将文件从bundle Document Directory传递到Appdelegate的代码:`

       func copyFile()
        {
            var documents: NSString
            documents = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as NSString
    
            let bundlePath = NSBundle.mainBundle().pathForResource("LeadWork1", ofType: "sqlite")
            print(bundlePath, "\n") //prints the correct path
            let destPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true).first!
            let fileManager = NSFileManager.defaultManager()
            let fullDestPath = NSURL(fileURLWithPath: destPath).URLByAppendingPathComponent("LeadWork1.sqlite")
            let fullDestPathString = fullDestPath.path
            print(fullDestPathString)
            print(fileManager.fileExistsAtPath(bundlePath!)) // prints true
    
    
            if fileManager.fileExistsAtPath(bundlePath!) == true
            {
                print("File Exist")
    
            }
           else
            {
                do{
                    try fileManager.copyItemAtPath(bundlePath!, toPath:   [enter image description here][1]fullDestPathString!)
                }catch{
                    print("\n")
                    print(error)
                }
            }
    
            let error  = sqlite3_open(fullDestPathString!, &database)
            if error != SQLITE_OK
            {
    
                print("Error while opening");
            }
            else
            {
                // print(fileForCopy)
                print(destPath)
                print("already open");
            }
    
        }`
    

    欢迎提供帮助!

1 个答案:

答案 0 :(得分:1)

启用以下内容:

选择项目 - >构建设置 - >架构标签 - >构建发布到YES

确保将“调试”和“发布”都启用为

它将解决您的问题。