I have a watch companion app that sends several message to the iPhone and the phone replies with the data the watch needs. This works perfectly on the simulator and when I deploy directly from XCode to my phone/watch. However, when deployed to test flight the watch never receives replies from the phone. I've added logging and WCSession is active, WCSession.isSupported is true and WCSession.isReachable is true. The watch just doesn't receive a reply from the phone. Is there something I have to put in the Plist to make this work in Test Flight? Has anyone ever had a similar problem?
Watch Connectivity
RSS for tagImplement two-way communication between an iOS app and its paired watchOS app using Watch Connectivity.
Posts under Watch Connectivity tag
56 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
There's another thread on here with similar Q but seems to have no resolution. So starting my own.
The basics
Xcode 15.3.0 beta 3
iOS 17.4
The WatchOS 10.4
I have an iPhone app with a companion watch app. In Xcode if I set the scheme to my iOS app it installs on my phone but the companion watch app does not auto install on my watch. Automatic App Install is turned on in Watch app on iPhone. To run the app on watchOS I have to run it directly from the watch scheme on Xcode. If I delete the app from the watch then go into the iOS watch app on the iOS device to install on my watch I receive an error "This app could not be installed at this time"
Is there a known cause solution?
I am developing issuer non-UI extension. In function status i have to return remotePassEntriesAvailable (boolean) and to do that i have to activate WCSession from that Extension to get the remoteSecureElementPasses which are already added to the remote wallet (watch).
I have implemented WCSessionDelegate inside the non-UI extension but i can not enable the WCSession. I always get:
Error: WCSession has not been activated
I saw a comment in this post -> WCSession is not available from iOS extensions, only from the main iOS app.
To the point... If the WCSession is not available from iOS extensions how can I properly set remoteSecureElementPasses and implement function remotePassEntries if i can't connect to the watch to see which cards are already enrolled?
I am experiencing difficulties in fully integrating my Apple Watch with a supervised iPhone under MDM control. While I have successfully paired the watch with the iPhone, I am facing issues with some apps not syncing or appearing on the Apple Watch. This issue persists despite having allowed their bundle IDs in the MDM’s whitelist. Could anyone provide guidance on which specific Apple bundle ID is crucial for maintaining the connectivity and functionality between the iPhone and the Apple Watch? Understanding this would help in ensuring that the necessary bundle ID is whitelisted in the MDM settings, thus resolving the app visibility and functionality issues on the Apple Watch.
⌚️Hello,
I've noticed in watchOS 10 that when a complication is in the Smart Stack, the value of WCSession.isComplicationEnabled is false. I'm not sure if this is intentional or a bug. It seems trivial at first glance, but it actually affects the communication mechanism mentioned in Implementing Two-Way Communication Using Watch Connectivity.
In the following two scenarios, if the user has only added the app's complication to the Smart Stack, then the watch app will not be able to communicate properly with the iOS app.
Scenario 1 - WCSession.transferCurrentComplicationUserInfo()
// update complications from the iOS app
if WCSession.default.isComplicationEnabled {
let userInfoTransfer = WCSession.default.transferCurrentComplicationUserInfo(userInfo)
// ...
}
As described in Implementing Two-Way Communication Using Watch Connectivity, when the iOS app proactively updates the data of the watch app, since WCSession.isComplicationEnabled is false, WCSession will refuse to transfer any data. This causes the standalone complication in Smart Stack to not be updated.
Scenario 2 - WKApplicationRefreshBackgroundTask
When the watch app uses WKApplication.scheduleBackgroundRefresh() to periodically update data, as long as the user has added the app's complication to the watch face, the corresponding WKApplicationRefreshBackgroundTask can be executed periodically in the background to fetch data.
However, if the user has only added complication to the Smart Stack, then the watch app will be completely purged, and the background task will not be executed at all. Although WCSession.isComplicationEnabled is not directly used in this scenario, its behavior appears to be the same, that is, the complication in the Smart Stack is not considered a complication by the system.
Should I submit a bug report?
I have paired two iWatch,the app in the second one can not have a reachable session with iPhone app
Xcode 15
iPhone 13 pro 17.1.2
iWatch S9 10.1
iWatch S9 10.1.1
I am trying to run the watch and iphone simulator at the same time. I have removed all simulators using Xcode Devices & Simulators panel and created a single iPhone with a paired Apple Watch to eliminate as many variables as possible. I have two schemes, my iPhone app scheme and a Watch scheme. The Watch is NOT set to run independently. My problem is that I can not start the iPhone simulator and the watch simulator and debug both at the same time. As soon as I start one or the other the currently running process is killed, making it impossible to debug both at the same time. I feel like I had this working at one point so I'm not sure if this is a regression or not. Using Xcode 15.1.
Hey there,
I'm implementing Watch Complications in an existing project, and I'm having the problem that transferCurrentComplicationUserInfo(_:) works exactly as transferUserInfo(_:) is described in the documentation, but not as it should.
That is, when the WatchApp is opened, func session(_ session: WCSession, didReceiveUserInfo userInfo: [String: Any] = [:]) receives the data sent by transferCurrentComplicationUserInfo(_:). If not, the data is queued until the Watch App is opened again.
In other words, transferCurrentComplicationUserInfo(_:) never wakes up the ExtensionDelegate when the Watch App is not running.
Has anyone experienced the same thing and know how to fix it?
More details:
Testing on iPhone 11 (iOS 17.1.2) and Apple Watch SE (WatchOS 10.2)
I made sure that the quota of 50 is not exhausted when I test.
The WatchApp is still dual-target (I want to avoid having to migrate to single-target and SwiftUI lifecycle)
Watch App code:
class ExtensionDelegate: NSObject, WKExtensionDelegate, WCSessionDelegate {
let session = WCSession.default
override init() {
super.init()
if WCSession.isSupported() {
session.delegate = self
session.activate()
}
}
func session(_ session: WCSession, didReceiveUserInfo userInfo: [String: Any] = [:]) {
WatchWidgetSessionHandler.shared.processComplicationUserInfo(userInfo)
}
}
IOS App code:
class WatchAppDataManager: NSObject, WCSessionDelegate {
override init() {
super.init()
let session = WCSession.default
session.delegate = self
session.activate()
}
func sendDataToWidget(for kinds: [WatchWidgetKind]) async {
guard
WCSession.default.activationState == .activated,
WCSession.default.isComplicationEnabled
else {
return
}
let widgetsData = dataProvider.getData(for: kinds)
if !widgetsData.isEmpty {
WCSession.default.transferCurrentComplicationUserInfo(widgetsData)
}
}
}
https://developer.android.com/build/configure-app-module#set_the_application_id
In Android, you can separate a mobile app and a wearable app into different projects and still enable communication by setting the same applicationId in both project's build.gradle.kts files.
Thus, one may upload mobile app and wearable app into google store separately, and yet be able to receive/send messages with each other.
Is there a similar approach available for iOS and watchOS apps?
I tried separating the watchOS app into a new project and setting its WKCompanionAppBundleIdentifier to the original iOS app's Bundle Identifier.
But I'm still encountering errors as below:
WCSession counterpart app not installed
SessionIsNotReachable
Am I missing something, or is this approach not feasible on iOS/watchOS?
Also, if it is not feasible, I would like to know why such approach is available on Android, but not on iOS.
If it is feasible, correction for my approach, or introduction of a new approach would be greatly appreciated.
I am trying to add a watch target in my existing project using XCode 15.1 but I am not able to see any watch simulators for this to run my watch app. I created a small sample project separately where I can see watch simulators reflecting in the run destination. Can somebody please help me to locate which property or setting I need to check which is disabling XCode to show watch simulators? I have downloaded the watch simulator.
When connecting my iphone (14pro with iOS 17.2.1) with a paired apple watch (series 9 with OS 10.3), it is not showing up on the devices/simulators list in xcode 15.1. Beyond unpairing/repairing the watch, restarting either iphone or watch, connecting/disconnecting the iphone from the computer or deleting xcode and re-installing xcode, any other suggestions? Under the WatchApp field it shows "no eligible device connected", however, under the console the Apple Watch does appear.
I have tried just about everything and can't get the watch to appear in Xcode. I am running all this on a MacBook Pro with Sonoma.
Thanks for any assistance!
The iPhone Target Build Phase for my Apple Watch companion app specifies the source of the Product to embed as: build/Debug-watchos, however,
the Watch build is located at build/Debug-watchsimulator.
I am receiving an error from Xcode when trying to install the Apple Watch app in the watch simulator, as follows: An application bundle was not found at the provided path. Provide a valid path to the desired application bundle.
Failed to install the requested application
Domain: NSPOSIXErrorDomain
Code: 2
Failure Reason: An application bundle was not found at the provided path.
Recovery Suggestion: Provide a valid path to the desired application bundle.
I have tried deleting the Watch target and re-adding the target but the misconfiguration remains. I have also tried adding my own Copy Build Phase but when selecting the Product for the Apple Watch companion app the same incorrect folder is used. Any ideas?
We are working on a WatchKit app that streams heart rate data to a companion iOS app. This works very well with WCSession, however, when the WatchKit app sleeps, the data does not continue to stream. The only way to get the data to stream again is by moving/touching the Apple Watch and waking it up again. We tried implementing a WKExtendedRuntimeSession, but we were unable to send data with this session. Is there a way to have data to continue to stream continuously, even if the watchkit app falls asleep?
WatchOS: 8.8.1
iOS: 17.0
XCode: 15.0.1
We are migrating ClockKit complications to WidgetKit in our watch app (watchOS 9+). The migration went smoothly, UI part works just fine. However, we've hit the wall with widgets not updating when requested by the watch app. I believe we are missing something very simple and fundamental, but couldn't find what exactly so far. Advice and tips would be very welcome! 🙇♂️
Our implementation details:
Whenever data is changed in the main app, the updated data is submitted to the watch app via WatchConnectivity framework using WCSession.default.transferCurrentComplicationUserInfo(_:). According to documentation, this method should be used to transfer complication-related data, since it will wake the watch app even if it is in the background or not opened at all.
Watch app receives updated data and stores it in UserDefaults shared with Watch Widget Extension hosting WidgetKit complications via App Group.
Watch app then request widget timeline reload via WidgetCenter.shared.reloadAllTimelines(). According to documentation, it reloads the timelines for all configured widgets belonging to the containing app, so it seems the appropriate way to reload WidgetKit complications.
Widget Timeline Provider class in Watch Widget Extension reads updated data from shared UserDefaults and uses it to provide the updated snapshot for widget views to render.
We believe our implementation logic is correct, but it doesn't work, for some reason. Widgets sometimes update when the watch app is opened, but not always. The most definitive way to force widgets to update is to switch to a different watch face, which confirms that the Widget Timeline Provider has access to properly updated data.
P.S. We are aware of the daily reload budget imposed on widgets, so we use widgets reload trigger sparingly. Anyway, according to documentation, reload budget is not effective when in DEBUG mode, but widgets won't reload even in DEBUG mode.
Thank you!
Right, this is getting on my nerves now. iOS app installed on iPhone via Xcode. Watch app installed on Watch via Xcode. Both apps are running and are in the foreground.
iOS app launches on iPhone and reports:
WCSession.isSupported = YES
theDelegate.session.isPaired = YES
theDelegate.session.watchAppInstalled = NO
theDelegate.session.activationState = Activated
I press a button in the Watch app. It reports:
session == activated and reachable
iOS app delegate receives a message from the Watch app:
didReceiveMessage (from Watch): message = {
action = giveMeUpdatedItems;
}
The apps must be installed on the devices in order for the Watch app to have used sendMessage (which is only available if the session is reachable, which it is).
iOS app delegate passes that through as a notification to another bit of code that collates the info and sends it back to the Watch app.
watchNotificationUpdateData; userInfo = {
action = giveMeUpdatedItems;
}
That bit of code in the iOS app checks whether we can send data to the Watch app, and doesn't send the data because:
WCSession.isSupported = YES
theDelegate.session.isPaired = YES
theDelegate.session.watchAppInstalled = NO
theDelegate.session.activationState = Activated
If I remove the check for watchAppInstalled, I get this:
Error sending Watch application context: Watch app is not installed.
{
NSLocalizedDescription = "Watch app is not installed.";
NSLocalizedRecoverySuggestion = "Install the Watch app.";
}
I've deleted and reinstalled the app on both devices countless times. I've rebooted the devices, plus the Mac. I've reinstalled Xcode. I've cleaned builds. I've deleted DerivedData. And still it says the companion app isn't installed.
I am having problems on Xcode13.3.1, Monterey 12.2.1, Apple M1 Max.
Sending an UpdateApplicationContext update from a paired iPhone simulator is not received on the paired Apple Watch Simulator in the didRecieveApplicationContext. However, sendMessage from the apple watch simulator does update the iphone simulator app properly. It is however, not possible to send anything from the paired iPhone simulator to the paired Apple Watch Simulator.
When working with actual devices everything works properly with WatchConnectivity with passing information back and forth via updateapplicationcontext and sendmessage calls.
Can anyone confirm this is a bug or if there is something wrong with my setup?