Debugging Apple Watch and iOS app simultaneously - xcode

Up until today, I've been able to build, run, and debug my watch app and iOS app at the same time. When I build and run, the debugger attaches to the watch automatically. Then I have to manually attach the iOS debugger. I have been following these steps and they always worked perfectly. I can hit breakpoints on both on the watch and the phone (which is what I need to do to be able to debug things like sendMessage or applicationContext).
The problem now is that when I go to attach the iOS app to the debugger manually (via Debug -> Attach to Process), it doesn't show up in the likely targets or in applications at all, even though the app is running on the phone.
I checked my schemes and made sure that the targets were still correct- they are.
I even tried Debug -> Attach to Process with PID or Name. When I try to attach the iOS app by name, I get an error saying Will install Watch App called with bad bundle identifier '(null).
Why is my iOS app no longer a likely target? How can I get it to attach to the debugger again while my watch app is also attached?

I use another way to debug on watch app and iPhone app at the same time. I run this script when watch and iPhone simulators are running on my Mac. Then launch my watch app or iPhone app on the same simulators. I can observe both log at the same time.
P.S. These log are come from console, so you should use NSLog(), not print().

Related

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.

Error Launching "WatchApp Extension" Install of Apple Watch Application never finished

First time i add WatchKit extension it was working fine, and then i remove all the watch app target and files.
but now i add the watch app to my project again, but i got that error when i try to run the app.
i already try to clean, uninstall the app, restart xcode and simulator, turn on and turn off keychain, switch off and on in Apple Watch app. all those solution doesn't work, i don't have any idea how to fix it,what should i do?
thanks.

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.

Can you get a crash log from iTunes Connect when you build on an app you downloaded?

Can you get an iTunes Connect crash log when you download your app from the App Store and then build on that app using Xcode?
Let's say I have a released version, and I download it from the app store to test, then later on I want to make some changes to my code.
I don't delete the downloaded app, but I just build over it from Xcode. Then I add a lot of breakpoints during the initial launch to check. Suddenly, my app crashes because it isn't able to launch in time.
Will the crash be sent to iTunes Connect?
Also, it is possible for your app to fail launching when you have a lot of break points added and you try to step into things?
I'm using Xcode 4.6.
Once you run your app from Xcode, your app is no longer the same app. It is now your development app. If it crashes, nothing is sent to iTunes.
When you run your app through Xcode, the timeout is disabled. You could let it sit for a week and the OS will not kill it for taking too long to startup.
And I believe you mean "iTunes Connect" where ever you mention "iTunes".

Resources