how to build connection between independent watch app and companion iOS app? - xcode11

I created a project with "iOS App with Watch App" template in XCode11(beta5), the project setting item - "Supports Running Without iOS App Installation" has been selected by default. The official doc shows that independent watch app can still use WatchConnectivity framework to transfer data, so I did it but it didn't work on simulator. I captured the error info with "Companion app is not installed". But it works When I uncheck "Supports Running Without iOS App Installation" (become dependent watch app).
How can I use WatchConnectivity to communicate between Watch & iPhone simulator when watch app is independent?

Related

How can I test a standalone watchOS application?

I can't figure out how to test running my watchOS app as a standalone app. When I run it on the simulator it never works unless I also have the associated iOS app. Running the watch scheme shows that the iOS app is running along with the watchOS app. I created a scheme which just builds the watch and it will cause the watch app to start, but it doesn't actually update the compiled binary.
First of all, you have to create certificates for all project targets and upload on Testflight, Through Testflight (mobile application) you can install the app and it will sync automatically in the watch.
The second option will, Connect your watch with mobile and install that watch application via Xcode on mobile, it will sync automatically in the watch.

Xcode fails to install watchOS app onto Apple Watch device

Xcode "Run" operation fails to install a watchOS app on a real Apple Watch device with error description:
The host is not paired with the device.
Context:
First time ever trying to install a watchOS app from Xcode onto an Apple Watch device for testing/debugging
The watchOS app is an official Apple SwiftUI tutorial example
Assume latest versions of MacOS, Xcode, watchOS, Watch device, etc.
The selected scheme is the watchOS app target
The selected device is "[my Apple Watch name] via [my iPhone name]"
The Apple Watch is in fact paired with the companion iPhone, despite what the Xcode error says
The Apple Watch has not yet trusted this particular Xcode, Mac, developer account, or app. The Apple Watch should have received a "trust/don't trust" notification, but did not; this may be a bug on Apple's part.
However, we can force the notification to pop up by simply restarting the Apple Watch device. The Watch should receive the notification immediately upon restarting. Click "Trust" in the notification on the Watch. Then retry, from Xcode, the "Run" operation. The watchOS app should now install OK on the Apple Watch device.
What needs to be done is restarting both devices, iPhone and paired Apple Watch, connect iPhone to computer with cable. When the trust/don't trust notification appears on the Apple Watch or iPhone obviously choose 'trust'. Then the app will install again.
What it stops from running on your watch sometimes is if you have a simulator debug session open still. It says it can't install because there is another debug session running (but not on your watch..)! Closing this simulator session will allow you to install on your watch.
Other times xCode is building fine and thinks it's running the app on your watch, but it runs an old version and you don't see any changes made. Then you have to delete the app from your Apple Watch.
What also sometimes stops it from running on the Apple Watch are in Xcode the Preferences->Accounts->Profiles. Installing them manually will help in that case.
If nothing works uncouple your apple watch from your iPhone and recouple again.
Why isn't this still been resolved? I see people complaining about it for several of years now. Is this bug only related to standalone apps?

Xamarin iOS Watch can't install on watch

I have an iPhone app on Xamarin working. I just added a Watch extension project. I can deploy the app on my iPhone device, but when I try to install it on my Watch device, it fails when it reaches near 100% (icon visible with progress), and then uninstalls. There is no error message either. Any idea why?
Does your provisioning profile include the watch device? Please see:
https://developer.xamarin.com/guides/ios/watch/deployment/device/
Testing iOS apps on a real iPhone or iPad has always required the device to be registered on the Dev Center...
Watches are no different - you now need to add your Apple Watch device before deploying apps to it. Find the watch's UDID using Xcode (Windows > Devices list)...
When you know the Watch's UDID, add it to the device list in the Dev Center:...
Once the Watch device has been added, ensure it is selected in any new or existing development or ad-hoc provisioning profiles you create:
So once you add your watch to the Devices in your Apple iOS Portal, you will have to regenerate and re-download your provisioning profile after including the watch device in the profile.

Archive Watch app application without iOS application

Ive builded a watch application for OS 2.x, and i wanted to submit the watch app to the app store without the iOS application. how can i do that ? what targets do i need to remove and so i can send the watch app standalone app without iOS ?
Do i have to submit both of them and apple will decide to take the apple watch application without iOS app ?
i tried to remove iOS application from targets. then the app stopped running on simulator. and couldn't be archived.
You can't do it. A watchOS application doesn't currently exist without a corresponding iOS application. If you are only updating the watch app, you still have to resubmit the whole thing, and the version of the iOS app must be incremented as well.

How to solve this error in Xcode when testing your app on the Apple Watch

I've tested my Apple Watch app on the simulator and it runs perfectly...However I couldn't test my app on the actual Apple Watch device:
I ran my iPhone app in Xcode.... Once completed it will install the app on Apple Watch.
Then, Apple watch app will launch and stuck on launching screen with "loading" spinner on the Apple Watch device.
The Apple watch will just close itself and this error will appear in Xcode:
You need to run the your iphone app scheme not the watchapp or extension scheme, once you will installed your iOS application on your device with watch kit support.
After installing the iPhone, you need to check your watch, application will automatically installed on Watch. If still you are not able to see the application then you need to visit application "Apple Watch" and scroll down to see your application and turn on apple watch support for your application.
If you are running the Watch OS2 app then after deploying the app on the Watch, you will need to reboot the Watch. Once rebooted, the Watch app will now run and not stuck anymore, loading time is about a few seconds only.

Resources