I am debugging an iPad app which background downloads data from a web service. Fully try/catch'ed.
While debugging from Monotouch, after a few minutes the app on the iPad crashes. However Monotouch doesn't catch anything.
In Visual Studio there is a "Break on all Errors" option in the debugger. Is there some feature in Monotouch which would allow me to break at the point of a crash on an iPad device and let me look at variables and stack traces etc?
Monotouch: 3.1.3
MonoDevelop: 2.4 (new beta)
Use a catchpoint on the Exception base class: Run->Exceptions and add System.Exception.
Related
I'm facing a strange error. App only crashes on physical device. But iOS simulator does not. It working fine.
The strange thing is it crashes when you open an app and FinishedLaunching(UIApplication app, NSDictionary options) method does not call at all.
What possibilities might have this issue?
One of the third-party iOS library (nuget package) was configured to iOS-Simulator. not physical iOS.
After the package author released hot-fix, it resolved.
try to change the linker Behaviour use the SDK-Only
go to Xamarin.iOS solution select ios build choose linker behaviour and change it
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
I migrated a project from the previous version of Xcode to Xcode 8. What I want is to use the new visual memory debugger. It's available in new projects, but is entirely missing in my imported one. Why is this?
It appears that Swift 3 is required for Visual Memory Debugger to work.
My app migrated to Swift 2.3 did not work, when I tried migrating it to Swift 3.0 it worked instantly.
The runtime sanitization checkbox is not required for visual memory debugger to work, however the reason that it is disabled is the same.
It seems like the project requires Swift 3 to enable Adress & Thread Sanitizer (which is the Memory Debugger).
For me this applies to both iOS & OS X/macOS apps. Both written in Swift 2.2 & converted to 2.3.
Note: I only tested this on OS X El Capitan 10.11.5.
#gabriellanata confirms that it works when the code is converted to Swift 3.
I just ran an Objective-C iOS 7 project made with Xcode 7 in Xcode 8 (without migrating) and the Visual Memory Debugger icon appears at the bottom of Xcode in the debugging area next to the Debug View Hierarchy button.
It's the button with the three circles.
From the other comments, it looks like Swift 3 might be required to use this feature.
Argument '-sanitize=address' is not supported on the Swift 2.3 toolchain.
You will need to migrate your project to Swift 3 to use this feature.
Xcode 8 GM build error
P.S. Objective-c supported by Visual Memory Debugger
If you click on Memory, the source editor pane will change to show some memory information, including why it's disabled. In my case, it was because I had Zombie Objects enabled in the Scheme. (Xcode 8.3.2)
So I recently had my app rejected by Apple. This is what they said:
2.1: Apps that crash will be rejected
----- 2.1 -----
We found that your app crashed on iPad running iOS 8 and iPhone 5s running iOS 8, which is not in compliance with the App Store Review Guidelines.
Your app crashed when we:
tapped on various menu items
If you have difficulty reproducing this issue, please try testing the workflow as described in Testing Workflow with Xcode's Archive feature.
I found it confusing why the app was only crashing on certain devices, especially the iPhone 5s. Since I don't personally own a 5s, I have been using the simulator and cannot recreate the crash. On the iPad retina simulator the app crashes when I press menu buttons and Xcode tells me the offending line is in the viewdidappear method of the view being segued FROM:
if( adBanner != nil )
{
adBanner.removeFromSuperview()
adBanner.delegate = nil
adBanner = nil
}
My questions are: How can I recreate these crashes on the iPhone 5s? How can I possibly fix this bug on the iPad or do I even need to? I assumed you could submit an app optimized to run on only certain iOS devices and that was determined by which devices you submitted screenshots for. Do I need this app to work for iPad or is there a way to just not publish it for iPad?
Mine was not also for ipad, but Apple still tested for that anyway.
I had the same issue. I was reproducing the issue on my ipad 2 when the project options is set to "link all assemblies" on my Xamarin project settings. The issue was not reproduced and the app on my ipad was working fine when I change options to only "link SDK assemblies only." This has been the reason with another app I published.
I'm going to try republishing the app again with that change in setting and hope for the best.
How can I recreate these crashes on the iPhone 5s
An iPhone 5c might reproduce the issue, but your best bet is to use an iPhone 5s. The simulator cannot possibly match behavior of the device when it comes to timing and memory characteristics.
You might be able to use guard malloc or NSZombies to find some issues related to memory mismanagement, so I suggest you try that out in the sim or on devices you own.
Do I need this app to work for iPad or is there a way to just not
publish it for iPad?
You can build an iPhone-only app that will be run in compatibility mode on an iPad, but there's no way to prevent someone from running your iPhone app on an iPad.
I create an extension for my app in iOS 8 and it is displayed correctly under the Today tab.
However when I make a change to the extension (either a UI change in the Storyboard, a UI change in viewDidLoad code, or some changes in the widgetPerformUpdateWithCompletionHandler method), there's nothing that is changed when I recompile. The only way I can make the changes to appear is to delete the app from the device/simulator then compile/install again. Restarting XCode (I work with XCode 6 beta 4) / restarting the computer does not help.
How can I fix the bug?
How am I supposed to debug the extension, because setting breakpoints does not seem to do anything and no NSLog messages are printed to the console (I suppose, since it's a different target).
It's a known bug, read the release notes for iOS 8b5.
Debugging (and NSLog) works in Xcode but not always (known bugs). You can still attach the debugger if Xcode cannot attach himself (Debug -> Attach to process)
For me, the simulator works better than real device, so use the simulator until things got better.
2 tips:
Close the simulator at end of debugging (i have a script for auto closing the simulator when i press STOP in Xcode, tell me if you want it).
When you launch the plugin process in simulator, wait for "All applications" display list, if you click "Run" before the list are loaded, the debugger won't attach.