8

I am making an independent Apple Watch app (but with a companion iPhone app which is not necessary for the watch app to function.)

The app uses WatchConnectivity to sync data between devices if iPhone companion app is installed. I am able to call session.updateApplicationContext() on the iOS app and receive session(didReceiveApplicationContext) on the Watch app. But going the other way is not possible. I always get an NSError code of 7018 which means the iOS companion app is not installed.

I have made sure both watchOS and iOS app are installed in simulator (and tested on my actual devices, iPhone 11 & Watch series 5.) But getting the same failed results from watchOS -> iOS.

I noticed there is a new WCSession instance variable available for watchOS 6.0+ isCompanionAppInstalled. When I read this variable after my WCSession is activated on my watch app, it always return false.

Is there anything else I need to look out for? I am thinking maybe there is something I did wrong in all the different info.plist. But I have checked them multiple times.


my info.plist files:

In my watch app:

 WKWatchKitApp is YES
 WKCompanionAppBundleIdentifier is com.abc.myapp

In my watch extension:

  App can run independently of companion iPhone app is YES
  NSExtension
    WKAppBundleIdentifier is com.abc.myapp.watchkitapp
    NSExtensionPointIdentifier is com.apple.watchkit
  • iOS app bundle identifier is com.abc.myapp
  • watchOS app is com.abc.myapp.watchkitapp
  • watchOS app extension is com.abc.myapp.watchkitapp.watchkitextension

Is there anything else I might be overlooking?

Thank you very much for any help/insight you can offer into this.

Cakelly
  • 401
  • 3
  • 9
  • I have tried to see if I can reproduce this with a brand new project. So I created a new iOS app with watchOS app project in Xcode. And I am getting the same error. Can anyone else reproduce this? I have filed a bug report with Apple. – Cakelly Feb 01 '20 at 17:16
  • Delete the key of "App can run independently of companion iPhone app" in Info.plist in Watch Extension works for me – Stoull Jan 04 '21 at 07:01

5 Answers5

12

Ok. I found a way to get rid of the error and have the watch connectivity work from watch to iPhone.

Originally I wanted the watch app to be independent so in the watch extension target in Xcode, the check box "Supports Running Without iOS App Installation" is checked. But as soon as I uncheck this box, WCSession.isCompanionAppInstalled returns true and error goes away. Syncing from watch to iPhone starts working.

So hopefully this is not intended behavior and will soon be fixed by Apple. (I filed a bug report.) But for now, I am just going to leave the independent watchOS app unchecked because I do want WatchConnectivity in case iPhone app is installed by user.

Thank you for reading and good luck with your programming.

Cakelly
  • 401
  • 3
  • 9
  • Did you submit a bug for this already? I have the same issue... – Renato Stauffer Feb 28 '20 at 10:14
  • Yes I have submitted a bug report. But I have been thinking maybe Apple doesn't want an independent watchOS app to have a companion iOS app. If a companion app is needed, don't make watchOS app independent. I am just guessing. Hopefully the documentation will get better at letting us know if this is intended behavior or not. – Cakelly Feb 29 '20 at 17:10
  • @Cakelly, Can you post your fix here since I am unable to connect watch to phone to share data, Your fix can help me to fix my issue. Thanks – Anilkumar iOS - ReactNative Mar 04 '20 at 17:57
  • @Cakelly you are life saviour. Thanks so much for your solution. Upvoted your query & solution. – Anilkumar iOS - ReactNative Mar 04 '20 at 18:08
  • Have you already published your app with those settings? I have the exact problem in that the documentation is very vague regarding "semi-dependent" watch apps (as I call them). – fruitcoder Apr 27 '20 at 13:10
  • I ended up just not making an independent watch app. So I published it as an iOS app with a companion watch app. – Cakelly Apr 28 '20 at 16:17
  • @fruitcoder I published an app with "Supports Running Without iOS App Installation" checked, but now that I am noticing WCSession is broken I can't submit again with it unchecked where can I go from here? – GarySabo Jul 11 '20 at 18:05
0

If you have "App is only available as a standalone watchOS app" in Info.plist, delete it even if it is false. Leave only "App can run independently of companion iPhone app". Also don't forget to set "WKCompanionAppBundleIdentifier" for Watch App (not extension). At least it works on real device for me with these parameters.

Flatout
  • 167
  • 2
  • 11
0

This seems to be a bug. Sometimes when I start my WatchOS app, it gets WCSession.isCompanionAppInstalled = false all the time, even though the companion app on the iPhone is running, and other apps are able to communicate with the phone.

This seems to go away when I force-restart the app on the watch (press side button, then swipe the app to the left and press the big red button, then start the app again). After the restart, everything seems to work fine.

This has happened only on Testflight builds so far. If it happens in production builds, I'm going to file a bug.

Jonas Sourlier
  • 13,684
  • 16
  • 77
  • 148
0

My iOS app will not launch in the Simulator if I uncheck "Supports Running Without iOS App Installation".

Mark Volkmann
  • 909
  • 12
  • 15
0

I encounter this issue in Xcode 14.2. Solution:

  1. set INFOPLIST_KEY_WKWatchOnly to NO
  2. add WKCompanionAppBundleIdentifier key in watch os app and set the value to iOS app's bundled ID
Bill Chan
  • 3,199
  • 36
  • 32