我已经通过领域创建了一个DB,我无法找到文件,因为我的操作系统(Yosemite)在/private/var/mobile中没有移动文件夹。
我应该如何访问我的领域以在浏览器中运行?
交叉张贴从谷歌组
我已经通过领域创建了一个DB,我无法找到文件,因为我的操作系统(Yosemite)在/private/var/mobile中没有移动文件夹。
我应该如何访问我的领域以在浏览器中运行?
交叉张贴从谷歌组
当前回答
对于那些使用React Native和使用默认域的用户:
Realm.defaultPath
其他回答
正如前面提到的,您可以使用next方法来查找文件位置
//code
Realm.Configuration.defaultConfiguration.fileURL
//lldb
(lldb) po Realm.Configuration.defaultConfiguration.fileURL
或者你可以手动找到它:
//Simulator
/Users/<username>/Library/Developer/CoreSimulator/Devices/<simulator-uuid>/data/Containers/Data/Application/<application-uuid>/Documents/
//for example
/Users/alex/Library/Developer/CoreSimulator/Devices/E1D084B0-CD97-41B4-871F-E131CA33F635/data/Containers/Data/Application/373721C7-2381-4E3D-9ABC-2147F748322F/Documents/
//iPhone (download a copy)
Xcode -> Window -> Devices and Simulators -> Devices -> <select device and app> -> App container actions -> Download Container... -> <selectfolder and navigate to it (.xcappdata)> -> Right Click -> Show Package Consents -> AppData -> Documents
*请注意,如果你为realm设置了文件名,并且它有一些其他扩展名而不是。realm, RealmStudio默认不会打开它
android和ios的所有步骤都可以在官方网站上找到: https://support.realm.io/support/solutions/articles/36000064525-how-do-i-locate-realm-files-on-a-device-or-simulator-
首先,我承认这是一个Android线程,但这是这个问题的第一个搜索结果。
要在Realm Browser中打开最近创建的Xcode Simulator Realm db,你可以在Automator中使用这个脚本,或者在终端中全部输入。通过使用Automator,我可以一键访问我的当前领域。
cd ~/Library/Developer/CoreSimulator/Devices/
cd `ls -t | head -n 1`/data/Containers/Data/Application
cd `ls -t | head -n 1`/Documents
open -a 'Realm Browser' ./default.realm
安装Realm浏览器。 在Automator中,单击新建,选择运行Shell脚本,粘贴代码,更改Realm Db名称,单击运行测试,将文件保存到方便快速点击访问的地方。
我不知道我第一次在哪里找到这个技巧,但这个帖子提醒了我过去是如何访问我的实时数据的。
Swift 2.3解决方案
更简单的解决方案,不会打破与领域更新
let dirPaths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)
print("App Path: \(dirPaths)")
realm文件应该在Documents中
我所做的就是利用
let realm = Realm(path: "/Users/me/Desktop/TestRealm.realm")
然后它就会在桌面上全屏显示出来,我可以双击打开Realm浏览器。稍后,当我满意一切都按预期工作时,我可以删除参数并让它使用默认位置。