ios - Realm Swift 仅在本地使用,但它仍会尝试在线连接

标签 ios swift realm

我正在关注 realm swift getting started guide here它工作正常。我有以下对象:

class Dog: Object {
  dynamic var name = ""
  dynamic var age = 0
}

在我的 View Controller 中有

override func viewDidLoad() {
    super.viewDidLoad()

    print(Realm.Configuration.defaultConfiguration.fileURL!)

    let myDog = Dog()
    myDog.name = "Rex"
    myDog.age = 1

    let realm = try! Realm()

    try! realm.write {
      realm.add(myDog)
    }
}

小告密者报告说 realm 试图连接到 static.realm.ioapi.mixpanel.com。如果我只想在本地使用它,如何阻止 realm 尝试连接到各种服务器?

最佳答案

这是预期的行为。

Realm collects anonymous analytics when your app is run with a debugger attached, or when it runs in a simulator.

有关详细信息,请参阅我们的文档。

https://realm.io/docs/swift/latest/#i-see-a-network-call-to-mixpanel-when-i-run-my-app-what-is-that

它不会发生在发布版本中。为了在调试构建中防止这种情况,请设置名为 REALM_DISABLE_ANALYTICS 的环境变量。

另见 https://github.com/realm/realm-cocoa/blob/master/Realm/RLMAnalytics.mm#L37-L44

关于ios - Realm Swift 仅在本地使用,但它仍会尝试在线连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45784877/

相关文章:

ios - topLayoutGuide 在导航 Controller 推送后移动

ios - Facebook 登录和 FBSDKLoginKit Pod 之间的差异以及使用哪一个?

具有多个 sortDescriptors 和 Bool 过滤器的 Swift fetchRequest

iOS 组合 : get a strongly typed error from URLSession's dataTaskPublisher

react-native - React-native 的 Realm 。重置数据库

swift - Realm 结果值未分配

android - 如何从 Realm 中的 ChangeListener 获取特定的变化

ios - CloudKit - 如何共享多个记录和检索共享记录?

java - 将 iOS 和 Android 客户端连接到 SockJS 后端

ios - 如果一个变异函数设置它自己等于另一个函数,这意味着什么