doZer
doZer

Reputation: 205

WC WCSession counterpart app not installed

Making a connection between iOS and iWatch devices, xCode writes [WC] WCSession counterpart app not installed.

After a lot of research, I've found a solution, maybe it will be helpful for someone.

- Check your WatchKit Extention target. 
- Uncheck "Supports Running Without iOS App Installation"
- First run iwatch simulator, than run ios simulator with checkmark

Upvotes: 17

Views: 7942

Answers (3)

Mahdi Moqadasi
Mahdi Moqadasi

Reputation: 2479

Finally, I made it. For anyone else, who has this problem:

  1. In iOS Target: Make sure in General>Frameworks, Libraries & Embedded Contents> Add YourWatchApp.app if it's not in the list. (For the loop problem, do the next step)

  2. In Watch Target: Go to BuildPhases>Copy Bundle Resources> and remove YouriOSApp.app from the list if exists.

  3. You must set delegate and activate it from both WatchApp and iOSApp as follows:

     self.session = WCSession.default
     self.session.delegate = self
     self.session.activate()
    
  4. if you are using a helper class, Your class should implement NSObject as well:

    class ConnectivityHelper: NSObject, WCSessionDelegate {
    
  5. Make sure there is some seconds between calling activate method and sending message.

  6. If you are using a reply handler when sending message from Watch, Then you must implement didReceiveMessage method in iOS App which has replyHandler, else replyHandler on the watch returns an error and the iOS app won't receive the message.

  7. Check out this complete code that is working: iOS Part:

    import WatchConnectivity
    
    class PhoneConnectivity: NSObject {
    
      override init() {
         super.init()
         let session = WCSession.default
         session.delegate = self
         session.activate()
       }
    
    }
    
    extension PhoneConnectivity: WCSessionDelegate {
      //MARK: Delegate Methodes
      func session(_ session: WCSession, activationDidCompleteWith activationState: WCSessionActivationState, error: Error?) {
      }
    
      func sessionDidBecomeInactive(_ session: WCSession) {
      }
    
      func sessionDidDeactivate(_ session: WCSession) {
      }
    
      // Receiver
      func session(_ session: WCSession, didReceiveMessage message: [String : Any]) {
         //without reply handler
      }
    
      func session(_ session: WCSession, didReceiveMessage message: [String : Any], replyHandler: @escaping ([String : Any]) -> Void) {
         //with reply handler
      }
      // end Receiver
    
    }
    
  8. send message with a test string first like:

     WCSession.default.sendMessage(["TEST", "TEST2"], replyHandler: { dictionary in
         print(">WC> reply recieved: \(dictionary.first!.value)")
     }, errorHandler: { error in
         print(">WC> Error on sending Msg: \(error.localizedDescription)")
     })
    
  9. Most developers suggest that make session active ASAP (in iOS using didFinishLaunchingWithOptions in appDelegate of iOSApp & applicationDidFinishLaunching in WKExtensionDelegate of WatchApp)

Upvotes: 4

Einzeln
Einzeln

Reputation: 567

I have spent around 3-4 hr to fix this issue, it seems that somehow my Apple watch.app is missing from my Target > Frameworks so after clicking plus icon and adding it back, it doesn't report "WC WCSession counterpart app not installed" anymore

Missing Watch app

Upvotes: 25

mskw
mskw

Reputation: 10328

It only worked for me by installing the Watch App from the watch settings app.

If I install the Watch App from xcode, the iOS app will give me the companion error message.

Upvotes: 4

Related Questions