PLCrashReporter : Creating a human readable stacktrace - stack-trace

I just downloaded compiled and added PLCrashReporter to my app. I've tested it and it works fine. The sample code from the project documentation works fine.
Now, I'd like to generate a stacktrace such that I can see where exactly the app crashed. Something you would get if you look into the iphone device logs when you connect your iphone to xcode:
What do I have to do to get such a nice stacktrace generated with PLCrashReporter?

The framework includes a text formatter in PLCrashReportTextFormatter.h:
NSString *humanReadable = [PLCrashReportTextFormatter stringValueForCrashReport:report withTextFormat:PLCrashReportTextFormatiOS];
NSLog(#"Report: %#", humanReadable);

You need to symbolicate the crash report by using the symbolicatecrash tool which is part of Xcode. This requires the dSYM package of the exact build that created the crash report to be available. There are multiple discussion on how to do that on StackOverflow.
There are also 3rd party services which do that automatically for you, including collecting the crash reports and grouping them by similarities, and also the open source project QuincyKit with a PHP server part that helps you to collect crash reports and automate symbolication from your own Mac.

Related

iPhone crash reports not found

i am trying to debug an Application I am developing using mono touch, but when I try to access Crash Reports in Xcode Organizer, I can't find any (and I know the app crashed at least 10 times).
I only see 5 files which process name is "Unknown".
I tried to locate the crash reports in
~/Library/Logs/CrashReporter/MobileDevice
But even there I couldn't find the reports.
Any ideas what Im missing?
Thanks!
Something similar happened to me before when I was trying to look at persistent connection logs, maybe it will be helpful to you. It turned out I was looking at /Library/Logs instead of ~/Library/Logs, the latter library folder is not visible but the former is.
I will suggest you to try and locate them in "Console" application and it shows hidden files by default. If Console cannot find them there should be a problem with logging.

iOS App with Static Lib crashes ONLY on launch of Archive Build loaded Ad Hoc. Can't reproduce in Debugger

I realize this is a stretch and I can't give much info to help but I am reaching for anything. My App has been under continuous development for 3 years and never seen anything like this. I recently submitted a small point release to Apple for Release, and twice now it has been rejected for Crashing on Launch on ALL their devices?
The Crash reports point to some code in static library but the key lines are not getting symbolicated. Tried Atos no luck.
The key point is that I have 7 devices I have tested the app on in every mode I can think of, in particular no connection to anything: Wifi-OFF, AirplaneMode-ON, Location services-OFF. I can NEVER simulate what they claim to be seeing, which is App crashes on launch every time?!
I found one report in the AAPL Dev Forums that sounded similar, but he never got any explanation as to what was up. After he submitted an app with loads of logging in it out of desperation and asked them to send the logs. They got that version and... approved it in hours.
Anyone have ANY ideas. I NEED to get this release out.
NOTE: Resolved
This turned out to NOT be a weak link issue. We only saw the crash when running the App using Ad Hoc distribution of the Archive version as Brad suggested... so that was helpful.
However the resolution turned out to be some compiler flags which I listed here:
https://stackoverflow.com/a/10302012/754494
I'll repost and expand upon my comment from above so that this question can have an accepted answer.
I recently came across a case similar to this when building my GPUImage framework. It appears that the build process is slightly different when archiving than when building and directly installing an application on the device via Xcode.
This can be exposed by building and archiving the application, then choosing to distribute it for ad hoc or enterprise distribution. Take the .ipa and place it in iTunes and manually load it on one of your test devices that way. The behavior of an application prepared in this manner may differ from one built and installed through Xcode, and should be closer to how a build submitted for review will act.
In my case, the problem was due to a lack of proper weak linking. On SDKs newer than iOS 4.3, you should no longer need to weak link whole frameworks if you wish to conditionally use classes and functions that are present in newer SDKs but missing in older ones. If you target 4.0 and higher, the linker should now perform class- and function-level weak linking.
However, this was failing for people using my static library, which does runtime checks for the presence of the new texture cache functions in iOS 5.0, but it only failed in these archived builds. I never saw it in all my testing against 4.x devices, because that was done by installing via Xcode. In the end, I needed to have users explicitly weak link the entire Core Video framework in order to get applications using this framework to run properly when archived and installed via iTunes.
Note that this wasn't due to the Release vs. Debug build configurations, because I tried switching between these in my build schemes when deploying to the device through Xcode and it made no difference there. Something else is different in the way that archived applications are built and linked.

how to get iPhone device Crash Log file without syncing to Itune

I need to access iphone crash log file via programmatically. I trying to write a crash report feature that when you launch the app after a crash, it will offer to send the crash report to the server. I can't find how to get the crash log within the app. I saw there is a framework that doing so (PLCrashReporter), however this framework is large and I don't need most of it's features. is any library or IOS code to read crash log file .
Check out http://quincykit.net/ for your self hosted php based solution, contains all you need. Or a hosted service, there are plenty out there right now.

Is there a way to automatically include the console output with the crash log on ios

The crash log returned when your app has an error on iOS is wonderful however it would be 100 times better if it contained the console output from when your app started as part of the log. Is there a way to automatically have that information in the crash log, or have a semi-automatic system that testers could use when sending in crash logs?
I think you might want to take a look at http://apphance.com. It's exactly what you are looking for - including capability of sending problem reports from device by testers, including screenshots, you can track history of session including full console logs, you can even see crashes from out-of-memory problems which are otherwise difficult to get without physical access to the device. It's closed beta for now but soon it will be open for everyone. You can request access directly at the page.
Disclaimer: I am CTO of Polidea, company which is behind apphance and co-creator of the service.
#Medran i am not sure if this will help but if you can get the Brad Larsons videos on Advance iPhone App Development than there he says some thing about .dSYM file that will help you find the places where crash occurs. .dSYM file is made when you build your app using Xcode. See if you can find that file in your project folder its named something like this MYapp.app.dSYM

Debug and Release Build works fine but the Distribution/AdHoc Crashes

HI there,
Some users of my application have reported me that my application is no longer working. It closes just after launching it.
I have been trying to identify the crash for days with no luck using builds debug and release and testing it in several devices. This morning I was surprised when I was able to reproduce the problem by generating a AdHoc version and installing it on my iPhone.
I have already tried to remove all the custom configurations and recreate them using a copy of the release version but it did not work.
I got this error below when I was running in the simulator and the crash reports also points to the same place...
Detected an attempt to call a symbol in system libraries that is not present on the iPhone:fwrite$UNIX2003 called from function -[My7zipExtract extract7zFile:]
So, my question is: What is the difference between build Debug/Release and Distribution (App Store/Ad Hoc). I have double checked everything and the only difference are the certificates.
Any help is appreciated.
Many thanks
I'm having precisely the same problem right now. I copied my Debug Xcode configuration to create the AdHoc one, adding entitlements and changing the certificate.
Doing good old printf-debugging ;) i found that the c++ constructors seem to be called differently / not called at all on the iPhone when using the AdHoc build.