title: Core Data fetch request with WatchConnectivity
body: <p>I'm currently trying to get CoreData data from my iOS app to the watchOS extension. I'm using the WatchConnectivity Framework to get a dictionary via the <code>sendMessage(_ message: [String : Any], replyHandler: (([String : Any]) -&gt; Void)?, errorHandler: ((Error) -&gt; Void)? = nil)</code> function. The basic connection is working fine. The iOS app is reachable and if I try to reply a sample dictionary everything is working.</p>
  
  <p>So far so good, but as I start doing a fetch request on the iOS app in background, the Watch App never receives data. After a while I just get this error: <code>Error while requesting data from iPhone: Error Domain=WCErrorDomain Code=7012 "Message reply took too long." UserInfo={NSLocalizedFailureReason=Reply timeout occurred., NSLocalizedDescription=Message reply took too long.}</code></p>
  
  <p>If I open the iOS app on the iPhone and relaunch the Watch App the reply handler is getting the result. But forcing the user to actively open the iOS app on the iPhone is useless.</p>
  
  <p>Can someone explain why this is happen? And what's the right way to do it? App Groups seem to be obsolete since watchOS 2.<br>
  I'm using Swift 4 btw…</p>
  
  <p>On Apple Watch:</p>
  
  <pre><code>import WatchConnectivity
  
  class HomeInterfaceController: WKInterfaceController, WCSessionDelegate {
  
  // (…)
  
  func session(_ session: WCSession, activationDidCompleteWith activationState: WCSessionActivationState, error: Error?) {
  
      session.sendMessage(["request": "persons"],
                           replyHandler: { (response) in
                              print("response: \(response)")
                           },
                           errorHandler: { (error) in
                              print("Error while requesting data from iPhone: \(error)")
      })
  }
  </code></pre>
  
  <p>On iPhone:</p>
  
  <pre><code>import CoreData
  import WatchConnectivity
  
  class ConnectivityHandler: NSObject, WCSessionDelegate {
  
  var personsArray:[Person] = []
  
  // (…)
  
  func session(_ session: WCSession, didReceiveMessage message: [String : Any], replyHandler: @escaping ([String : Any]) -&gt; Void) {
  
      // only using the next line is working!
      // replyHandler(["data": "test"])
  
      if message["request"] as? String == "persons" {
          fetchAllPersons()
  
          var allPersons: [String] = []
          for person in personsArray {
              allPersons.append(person.name!)
          }
  
          replyHandler(["names": allPersons])
      }
  }
  
  // this seems to be never executed (doesn't matter if it's in an extra function or right in the didReceiveMessage func)
  func fetchAllPersons() {
  
      do {
          // Create fetch request.
          let fetchRequest: NSFetchRequest&lt;Person&gt; = Person.fetchRequest()
  
          // Edit the sort key as appropriate.
          let sortDescriptor = NSSortDescriptor(key: #keyPath(Person.name), ascending: true)
          fetchRequest.sortDescriptors = [sortDescriptor]
  
          personsArray = try DatabaseController.getContext().fetch(fetchRequest)
      } catch {
          fatalError("Failed to fetch: \(error)")
      }
  }
  </code></pre>