This here i have shared to show that i have Sqlite
file present in copy bundle resources : 我在iOS
应用中使用Sqlitecipher在Simulator
(离线)中运行我的应用时,它会成功显示所有数据,并且每个查询都能正常工作,如(更新,删除,插入),但在设备上测试我的应用时,它并没有显示任何内容。按照我试过的方式:
Sqlite
个文件包Sqlite
文件复制到Document
Directory
Simulator
删除应用并重置我的Simulator
,但我仍面临同样的问题。请建议解决方案( Salesforce本地应用程序)这是将文件从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");
}
}`
欢迎提供帮助!
答案 0 :(得分:1)
启用以下内容:
选择项目 - >构建设置 - >架构标签 - >构建发布到YES
确保将“调试”和“发布”都启用为是。
它将解决您的问题。