我正在使用数据线在我的真实 iPhone 6 设备上调试应用程序。我想要检查我的数据库并使用 sqlite3 查询结果。其他问题和教程只讲解如何在模拟器中操作,但我正在使用真实的 iPhone。
在 AppDelegate 中,我打印了数据库路径:
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/Documents
因此,我获取该路径并从终端访问,并使用 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
这个错误发生了,我认为是因为这是 iOS 系统的文件路径。