WC WCSession counterpart app not installed
Asked Answered
T

3

17

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
Trictrac answered 8/3, 2020 at 17:46 Comment(2)
i have the same issue, but not fixed with above oneMotorist
i am using xcode 12 is there any issue in xcode 12Motorist
D
24

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

Digitalis answered 2/11, 2021 at 9:26 Comment(6)
It worked for me. Everybody who struggles with that problem, check that solution.Dagnah
Thank you, I've been struggling with this for daysWoehick
Worked for me as well. In addition to this, I needed to add the original apps bundle id into the WKCompanionAppBundleIdentifier key in the info tab, under my new watch app target build screenHumid
I tried this solution but then getting following error while building the project "Cycle in dependencies between targets 'IOS_App' and 'Watch App'; building could produce unreliable results."Lustihood
cycle error appears for me tooAnalisaanalise
Also had to enter the WKCompanionAppBundleIdentifier in to Watch App > Info. The key was there but blank. Also my bundle identifiers in the watch app and widget were missing the prefix of the phones bundle identifier. Xcode gave decent errors though.Involve
A
4

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.

Admetus answered 1/4, 2021 at 2:14 Comment(4)
Thank you, thank you, thank you! I got my first WCSession message after a day of experimenting! :)Overgrowth
my watch app does not appear on the Settings app, any idea?Phenetidine
You should add watchApp in iOS target frameworks. for fix loop err and some advice, check my answer.Analisaanalise
Yes This is the best answer and it really work thank you, only I do it from the phone not from the watch using the watch app in the phone, but thanks and its fantastic.Disinter
A
4

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)

Analisaanalise answered 15/12, 2022 at 20:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.