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

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.

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?

WatchOS5 - how to debug an apple watch app?

I'm brand new to watchOS development - have my first app and extension. I have the following questions:
Are breakpoints available for watch OS extensions and apps? I set them, but they don't seem to trigger
Does the app fail to appear on the watch if there's a fatal crash during launch? It seems when I make a mistake, the app simply fails to install and I get almost no info in console and no stack trace of any kind.
How do I debug a WatchOS5 app is there some option I need to enable on device or XCode?
You can select watch complication or extension from the list of schemes in the run menu and run the app on watch and device. I was running the test app only.
The bad news is that the process times out on my old Macbook air when trying to run on device. And the watch Simulator is terribly slow, working at about 2 FPS.

Xcode Run Apple Watch target results in Finished running app on Watch

I am trying to debug my watch app. I build and try to run as usual. It says Build succeeded, installing to watch etc. but then, instead of launching my app, it says Finished running app on watch. I've restarted Xcode, reinstalled my app on watch etc. but no avail.
What am I doing wrong?
I've also restarted my Mac, my iPhone and my Watch. It then worked.
I restarted everything and it still didn't work. However, after the restart when I first run the app I received an error: Device doesn’t support wireless sync. With this, after disabling the wifi on the watch, things went back to normal.
From my experience, restarting all devices (iPhone, watch, and mac) sometimes allows the app to build on the watch, but it is very frustrating and a long process for a "maybe."
Especially when I get the Device doesn't support wireless sync. the most consistent solve has been disabling wifi on both the watch and the iPhone. Also, have the iPhone connected directly to the computer with a genuine cord.
Good luck.
Also, if you were using the simulator, stop it and quit the simulator before trying to compile to the real device.
You just have to attach the Xcode debugger to the process which is running on the watch!
Xcode -> Debug -> Attach to Process > "name of your app watch extension"
After that Xcode displays "Running ... Extension on Apple Watch" and you can start debugging

How do I attach debugger to an app running on the Apple Watch?

I want to debug my Apple Watch app in the same way as when it is being run on the simulator. When running on the simulator, Debug > Attach To Process will show the apple watch app, but this does not show up when running the app on a real Apple Watch. Any suggestions?
When running, make sure your apple watch application and device are selected on the dropdown menu. This way it should attach automatically when running.

Resources