如何在 iPhone 真机上打开数据库 sqlite 文件? [英] How to open database sqlite file on iPhone real device?

查看:64
本文介绍了如何在 iPhone 真机上打开数据库 sqlite 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过电缆在我的真实设备上调试应用程序.我有一部 iPhone 6.我想检查我的数据库并使用 sqlite3 来查询我的结果.其他问题和教程说明只能在模拟器中执行此操作,但我使用的是真正的 iPhone.

I'm debbuging a app in my real device by cable. I've a iPhone 6. I want check my database and operate with sqlite3 to query my results. The other questions and tutorials explain to do this only in simulator but I'm using a real iPhone.

在 AppDelegate 中,我打印数据库的路径:

In AppDelegate, I prints the path of database:

print(NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).last! as String)/Users/myname/Library/Developer/CoreSimulator/Devices/DAE93E57-7004-45F6-9B93-E79CA1AEEEFA/data/Containers/Data/Application/D7A4F27E-6F11-4941-A1B0-0337ABF788AB

因此,我从终端获取路径和访问权限,并使用 sqlite3 DatabaseFile

So, I take the path and access from terminal and access my database with sqlite3 DatabaseFile

但是当我在我的设备中调试时,打印的路径不起作用.我尝试使用打印的路径<代码>cd/var/mobile/Containers/Data/Application/3257D423-C198-41A5-B29D-B31E99F84F34/Documents/usr/bin/CD: line 4: cd:/var/mobile/Containers/Data/Application/3257D423-C198-41A5-B29D-B31E99F84F34/Documents: No such file or directory

But when I debugging in my device, the path that's printed not works. I tried use the printed path cd /var/mobile/Containers/Data/Application/3257D423-C198-41A5-B29D-B31E99F84F34/Documents /usr/bin/CD: line 4: cd: /var/mobile/Containers/Data/Application/3257D423-C198-41A5-B29D-B31E99F84F34/Documents: No such file or directory

发生这个错误是因为这是 iOS 系统,我认为.

This error happens because this is of iOS system, I think.

推荐答案

Xcode 10.1

在 Xcode 中,转到窗口 > 设备和模拟器

In Xcode, go to Window > Devices and Simulators

设备选项卡中,选择您的应用程序,然后单击齿轮图标,然后单击下载容器...

In the Devices tab, select your application, then click on the Gear icon, then click Download Container...

选择您要保存文件的位置,然后点击保存.

Choose the location you want to save the file, then click on Save.

转到 Finder 并找到您刚刚下载的 .xcappdata 文件,然后右键单击并选择 在目录中显示包

Go to Finder and find the .xcappdata file you just downloaded, then right click and select Show Package in Contents

内容文件夹将打开.您的 .sql 文件位于 AppData > Library > Application Support

The contents folder will open. Your .sql file is in AppData > Library > Application Support

我建议下载DB Browser for SQL File,然后打开.sql 文件.它创造了奇迹!

I recommend downloading DB Browser for SQL File, and opening the .sql file with that. It works wonders!

这篇关于如何在 iPhone 真机上打开数据库 sqlite 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆