I am having trouble finding a workable solution for debugging nativescript applications. I have tried the following options:
a) tns debug
This starts a tool called 'Nativescript Inspector'. It is painfully slow and to add insult to injury: it crashes more than it runs. I have not been able to it to run long enough to find even basic problems. It's perfectly useless to me.
b) tns debug --chrome
The chrome debugger is a lot better, but it seems impossible to simply reload. Every time you restart, you need to re-attach a fresh instance. Since this option works by copy & paste of a link, it becomes fairly cumbersome. Additionally, it does not really respect breakpoints properly, especially during app restarts! So ultimately, this is also useless.
c) Sidekick
This is supposed to be one of the prescribed methods of debugging. Half the time the debugger does not start. If it does, there is no way to break the flow during application start-up. Since I'm in the process of debugging parts that happen during start-up, I do never get a chance to set a breakpoint, barring tricks like wrapping the bootstrapping phase into a timer (which also costs time). So even this method is not working.
Do I really, really need to get Visual Studio? I really would like to avoid that ...
To debug the Views, currently, the best option is to use the debugger that comes with Sidekick.
If you want to debug the logic, however, the best option is to use the NativeScript extension for VS Code, and debug directly from VS Code. :)
Hope this helps.
https://marketplace.visualstudio.com/items?itemName=Telerik.nativescript
Debugging code that executes at start up is tricky, so you need to place debugger statements in your code, and start a debugging session with --debug-brk
tns debug ios --chrome --debug-brk
For more information, check the Debugger section in the Chrome DevTools docs - https://docs.nativescript.org/tooling/chrome-devtools#debugger
I´m starting with native script and I found that debugging is one of the biggest challenges.
My first approach was the native script extensión for Visual Studio Code, but it resulted a little bit unstable and Visual Studio Code lacks some features that I use a lot in webstorm.
Probably in a near future VEC + tns extension will be the choice, but right now my debugging strategy is:
1 Launch simulator
I'm using Osx and I want to debug in an Ipad simulator. By default the IOS simulator boots an Iphone X device. First I need to launch the simualtor with a custom device.
$ xcrun simctl list devices
== Devices ==
-- iOS 11.2 --
iPhone 5s (E3B6EA43-C805-49C2-9502-A44A465D8DF2) (Shutdown)
iPhone 6 (801E9E11-CA86-473A-9879-4B0742B827FB) (Shutdown)
iPhone 6 Plus (24013349-1A6F-489C-9A68-ABB00EBB4BBF) (Shutdown)
iPhone 6s (1A594D75-146C-4BEA-A250-1FADE7886114) (Shutdown)
Then I launch the simulator app specifying a device with the -CurrentDeviceUDID option
/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator -CurrentDeviceUDID <DEVICE-UDID>
NOTE: replace the with a valid UDID from the list.
More info at Xcode 6 - Launch simulator from command line
2. Use nativescript-cli commands
To get a list of available devices
# tns devices
To debug in a specific device:
# tns debug ios --device <device identifier>
Note: replace the device identifier with a valid id.
If you want to debug in an emulator
# tns debug ios --emulator
You have to find the url in the command output and open in chrome:
...
...
To start debugging, open the following URL in Chrome:
chrome-devtools://devtools/remote/serve_file/#02e6bde1bbe34e43b309d4ef774b1168d25fd024/inspector.html?experiments=true&ws=localhost:41000
....
More information about dedugging commands can be found in
https://docs.nativescript.org/tooling/debugging
More information about debugging with chrome-dev-tools
https://docs.nativescript.org/tooling/chrome-devtools#debugger
04/20/2018 Update
I´m developing in Mac OS X and with the new native-script cli 4.0 the debugging experience with the WebKit Web Inspector has improved. So I´m now using it for debugging:
tns debug ios --inspector
Related
I'm using version 12.4 of Xcode, and when I run my app to test it, the debugger never starts a session. When I open the Debug Navigator, the message "No Debug Session" stays, and none of the normal analytics data appears.
I am running my app through Xcode onto my iPhone 12 Pro. It requires the use of the camera, and in fact the part I need the debugger for also requires the camera, so I can't use a simulator to see if that magically fixes it.
I also looked through every setting I could find that mentioned "Debug" or "Debugger", but nothing I could find changed anything.
Also, I downloaded a random tutorial app and ran that through Xcode on my iPhone, and the debugger boots up as expected.
I am completely lost and really need a GDB/LLDB tool to debug my code, so any help is greatly appreciated, as I could not find a single person or post with a similar problem to mine, and all of the Debugger tutorials and Apple Documentation are outdated and useless.
EDIT: Here is the Scheme info I have set, I have nothing in the Arguments tab. (This is a new account so I'm not allowed to embed images RIP)
Scheme Info
Scheme Options
Scheme Diagnostics
As Matt pointed out, the debugger will not point at the app target if the Executable dropdown (in Scheme Info) is "Ask On Launch". It must have the app itself selected.
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.
I'm rewriting my watch app to work in watchos2 but have problems debugging on the actual watch (XCode7). What is the correct way how to do this?
1) Obvious (but naive) approach - connect your phone with paired watch, in XCode select Extension scheme to run on Phone + Watch. Click play and it should work, right? This seems to work only just after fresh pairing and breaks very quickly (after few debug runs). See issues and behaviour below
2) Run phone app first then add run of extension - this approach worked for me longer but eventually broke as well.
3) Unpair and pair again - more than painful experience, time consuming and not practical at all. Will help for a while though.
Main problems:
phone app not communicating - I've seen not reachable or messages just time out
watch app stops running - XCode is saying it's running but it's not - won't even attach. If I run it manually on watch most of the times it will attach but then the phone app is not reachable
watch app won't even install - I suspect when the XCode is saying it's running it in fact it doesn't because when I remove the app from watch and then run XCode goes through the whole install process and "running" but the icon doesn't even appear on the main screen
phone stops reacting when I use option 2) and try to run something else while app is attached
phone seems to be blocked, selecting other apps (even going back to my app) won't work until I kill the session
Setup: The phone and watch is paired correctly, phone can see watch, watch can see phone, other apps are working. Watch "trusts" the computer as well, app is "shown on apple watch". Phone is 5s 9.0.1.
I've tried various restart combinations (phone|watch|xcode|mac), shuffled cables, disconnect, reconnect, etc. but that didn't help either.
Did anybody find a usable way how to debug watchos2 app from XCode? Nobody else seems to be complaining about this with released XCode7 though I've seen lots of similar issues in beta builds.
Use Apple watch recharging cable, connect your watch to developing Mac that runs Xcode.
It provides much more successful and fast debugging.
I have been dealing with the same issue this last days, I just updated to iOS 9.2, watchOS 2.1 and XCode 7.2, and now everything works.
After update XCode to 7.2, iOS9.2 my phone and WatchOS2.1 my Apple Watch the debug process is better. I suggest to update all your devices.
Xcode 4.2+ and Xcode 5 have a very powerful debugger for OpenGL ES. Until recently, the debugger itself would crash often (it didn't work reliably for me until Xcode5.0), but it sometimes disables itself and refuses to run at all.
This being an Apple application, they don't bother with error messages, they simply refuse to let you press the Analyze button:
I can't find any reference in Apple's docs to a situation that would "disable" the analysis. I know that it can work on this machine, because it worked fine on a different device.
Device that works:
iPad3, running iOS 6.x
Device that Xcode5 refuses to work with:
iPad Mini, running iOS 7.x
...I've tried updating to latest 7.x - no change. Xcode just refuses to work properly. All other debugging works fine.
It's not a perfect answer, but I've noticed something that might explain it...
When you pause the debugger, this triggers the button to grey-out. So, if you needed to analyse the frame at a particular point in your app ... you can't.
It sucks, and I have no idea how you're supposed to debug something without using the debugger, but ... it might be why I was getting disabled button!
Can anyone point me to the documentation on how to make Instruments run UIAutomation scripts and start the iPhone application with the debugger running in the Simulator?
Constraints:
I only have iPhone 3g hardware to test with and debugging against the device with UIAutomation just does not reliably work.
Normally the test scripts are just ran to make sure everything passes, but now a weird bug exists that only gets triggered when the UIAutomation script runs (which is a good thing). The bug cannot be duplicated in manual operation.
There does not seem to be anyway to attach Instruments UIAutomation to a process already running in the simulator. There is no selection.
Starting Instruments UIAutomation directly does not cause it to start with the debugger.
I would assume that there is some command line magic that can be configured in Instruments edit active target (environment variable, arguments, working directory) to make this happen, but I've not found the magic paragraph.
Thanks,
Neil
This stumped me for a while, too -- especially since when the Automation Instrument is selected, the Instruments application explicitly says Current instrumentation disallows attach. The key is to realize that an app running in the simulator is visible in your host system as its own process, so attaching directly from GDB works well. These instructions are for XCode 4.2 (4C199) on Snow Leopard 10.6.8:
Start your test in Instruments however you normally do (either directly from Instruments, or from Xcode 4's Product -> Profile. Pick whatever templates and scripts to get your automated test underway.
Back in Xcode, under the menu Product -> Attach to Process, you should see your iOS app, listed by name, alongside all the other applications on your host computer. In fact, it very likely will be listed first, under the section header Likely Targets.
If it's not visible, choose View -> Debug Area -> Show Debug Area so you can see the gdb console.
Hit the pause button (Product -> Debug -> Pause) to interrupt your program. Set breakpoints, inspect, as usual.
Then next question is: why can't I see my normal NSLog() output in the debugger console?
Your app already bound itself to the console output streams, so the simplest place to look for its output is in OS X Console app (/Applications/Utilities/Console.app) and look under DATABASE SEARCHES -> All Messages.