build settings to generate proper dSYM - ios

I have a question regarding dSYM. I made an experiment with my app and added following code to it:
if (currentMenuPage_ == MenuPageAttrsVals) {
return ((ValueAndId *) [currentValues_ objectAtIndex:-1]).name;
}
as expected application crashed and crash log was generated.
However Xcode and atos can not tell me exact line where the crash is.
2 CoreFoundation 0x3192c23d -[__NSArrayI objectAtIndex:] + 165
3 MyApp 0x00053487 0x49000 + 42119
4 MyApp 0x0005102d 0x49000 + 32813
Do I have to set some special settings when building my app to generate proper dSYM?
If I call dwarfdump --uuid MyApp.app.dSYM I get a number. Does this number should appear somewhere in my crash log?

That number should appear in the first line under the Binary Images section. (It might be formatted differently, e.g. lowercase and without the - chars).
Please remember, every time you do a build, this UUID changes, and if you did not save the previous dSYM, it won't symbolicate it.
If you did not change a lot (any) code, you could replace the UUID string in the Binary Images section (keep the format in there) with the new one from the latest dSYM.
If symbolication did not work, and the UUID is correct, that folder is most likely not indexed by Spotlight, so the symbolication script can't find the dSYM.

Related

Crash-safe append() in Swift

After updating to iOS 14 Developer Beta my app began crashing. Mainly it happens on line axis.entries.append(Double(f)) of the library which I use for creating charts. Here is the console output:
Fatal error: UnsafeMutablePointer.initialize overlapping range: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-1200.2.19.2/swift/stdlib/public/core/UnsafePointer.swift, line 832
Fatal error: UnsafeMutablePointer.initialize overlapping range: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-1200.2.19.2/swift/stdlib/public/core/UnsafePointer.swift, line 832
I don't believe I can fix this library, so I want a simple solution just to prevent my app from crashing. This line axis.entries.append(Double(f)) is being called multiple times without crashing, so what I want to do is to perform this append if it won't crash my app and don't perform append if it will. Is there a way to implement this?
I have tried putting this line inside try and if, but with no result.

line numbers in stack trace

The line numbers in stack traces for IOS builds do not seem to
correspond to either the original sources or the .m sources generated
by the build process. Is there a way to interpret them ?
For example, in the trade below online_root.start:721 is refers to
a method in a file with only 111 lines. The correspinding .m file
has only 319 lines.
*** CN1 log ****
[null] 0:0:48,666 - Exception: java.lang.NullPointerException - null
java.lang.NullPointerException
at online_Root.start:721
at util_JWSApplication.runMain:216
at util_JWSApplication.xmain:124
at com_boardspace_BoardspaceLauncher.launchLobby:110
at com_boardspace_BoardspaceLauncher.doit:0
at com_boardspace_BoardspaceLauncher.run:51
at java_lang_Thread.runImpl:153
*** End of CN1 log ****
Try using a platform for crashing such as HockeyApp or Crashlytics, that would be easiest way to interpret the crash logs on an iOS device. If you don't go that route, you will need to understand the atos command, basically address to symbol. There are plenty of resources here about atos and how to get it working, this is the route I took and works well.

iOS: convert stacktrace entry to method name with line number

In a production app with the debug information stripped out, how do you convert the output of:
NSLog(#"Stack Trace: %#", [exception callStackSymbols]);
To an legible class and method name? A line number would be a blessing.
Here's the output I'm getting:
0 CoreFoundation 0x23d82f23 <redacted> + 154
1 libobjc.A.dylib 0x23519ce7 objc_exception_throw + 38
2 CoreFoundation 0x23cb92f1 <redacted> + 176
3 MyApp 0x23234815 MyApp + 440341
The final line is the bread and butter line, but when I use dwarf to find the address, nothing exists.
dwarfdump --arch armv7 MyApp.dSYM --lookup 0x00234815 | grep 'Line table'
I've read here that you need to convert the stack address to something else for dwarf or atos:
https://stackoverflow.com/a/12464678/2317728
How would I find the load address or slide address to perform the calculation? Is there not a way to calculate all this prior to sending the stacktrace to the log from within the app? If not, how would I determine and calculate these values after receiving the stack trace? Better yet, is there an easier solution I'm missing?
Note I cannot just wait for crash reports since the app is small and they will never come. I'm planning on sending the stack traces to our server to be fixed as soon as they appear.
EDITORIAL
The crash reporting tools in iOS are very rough, particularly when compared to Android. In android, the buggy lines are sent to Google analytics, you use the map to debug the line--simple (comparatively). For iOS, you are confronted with: a) waiting on user bug reports (not reasonable for a small app), b) sending stack traces to a server where there are scant tools or information on how to symbolicate the stack traces, c) relying on large quasi-commercial 3rd party libraries. This definitely makes it harder to build and scale up--hoping Apple will eventually take notice. Even more hopeful someone has spotted an easier solution I might have missed ;)
Thanks for your help!
A suggestion, you can easily get the method name, exception reason and line number using:
NSLog(#"%# Exception in %s on %d due to %#",[exception name],__PRETTY_FUNCTION__,__LINE__,[exception reason]);

How to know which line is causing exception?

I am new to XCode and Objective C. I have intentionally make a mistake to assign number to NSString*.
NSString* s = #1;
[s uppercaseString];
Though XCode gives me warning, this code will compile. But at runtime I get exception. Now I see in logs, (Sorry for image, I was not able to paste is as text properly due to formatting)
In this log, how I find exact place of error. How this log tells me which code to change.
So it looks like you are running the Release build (debug symbols stripped) and if you got that crash log in a production environment you would need to symbolicate it in order to find the line.
This Apple TN gives some details of Symbolication.
In a development environment you would simply add an exception breakpoint and run it from Xcode, as the debug symbols would not be stripped.
To understand what line causes the problem, you usually need to add exception breakpoint to your project as explained in this document;
In the bottom-left corner of the breakpoints navigator, click the
Add button.
Choose Add Exception Breakpoint.
In the Exception pop-up menu, choose the type of exception on which
you want execution to stop:
All. Stops on all exceptions.
Objective-C. Stops on Objective-C exceptions.
C++. Stops on C++ exceptions. To stop on a particular C++ exception, specify the exception name.
Choose the phase of the exception handling process at which you want program execution to stop.
Click Done.
line 5 Sam : [BIDViewController viewDidLoad] + 143 , if this is a release build , you need to resolve with symbols the memory address of the function , this is called "symbolize" the crash dump...
In the log look for your project name and you will come to know.
e.g.
line 5 Sam : [BIDViewController viewDidLoad] + 143
If you want to produce real crash without warning, try following code it will produce index out of bound exception and will crash
NSArray *array = #[#"1",#"2"];
NSLog(#"Item not accessible->%#",(NSString*)array[2]);
set Exception breaking point or enable NSZombie object
or
NSZombie
From the menu bar, choose Project > Scheme > Edit Scheme

Error 255 in Xcode 4.5 compiling with LLVM 4.1

I'm trying to compile my project with the latest xcode + sdk 6.0
when the building is almost done, I got this error:
2012-09-26 16:52:24.714 ibtoold[5603:b03] [MT] DVTAssertions: ASSERTION FAILURE in /SourceCache/IDEInterfaceBuilder/IDEInterfaceBuilder-2840/Framework/Document/IBDocument.m:1514
Details: Some objects didn't get the ibBeginArchivingDocument:withContext: callback. A class has probably overridden the method without calling through to super.
Object: <IBCocoaTouchDocument: 0x40072df00>
Method: -willArchiveWithContext:
Thread: <NSThread: 0x40010a260>{name = (null), num = 1}
Hints: None
Backtrace: 0 0x000000010550e44c -[DVTAssertionHandler handleFailureInMethod:object:fileName:lineNumber:messageFormat:arguments:] (in DVTFoundatio
1 0x000000010550e2a5 _DVTAssertionFailureHandler (in DVTFoundatio
2 0x0000000104b35245 -[IBDocument willArchiveWithContext:] (in IDEInterfaceBuilderKi
3 0x00000001086407d6 (in IDEInterfaceBuilderCocoaTouchIntegratio
4 0x0000000108640c3a (in IDEInterfaceBuilderCocoaTouchIntegratio
5 0x0000000104b44745 __47-[IBDocument compiledPackageWithOptions:error:]_block_invoke_0 (in IDEInterfaceBuilderKi
6 0x0000000104b5b9a1 -[IBDocument assertIfArbitrationIsScheduledDuring:] (in IDEInterfaceBuilderKi
7 0x0000000104b44710 -[IBDocument compiledPackageWithOptions:error:] (in IDEInterfaceBuilderKi
8 0x0000000104a46f90 (in ibtool
9 0x0000000104a440e8 (in ibtool
10 0x0000000104a43c5f (in ibtoold
11 0x0000000104a43b53 (in ibtoold
12 0x0000000104a50165 (in ibtoold
13 0x0000000104a43684 (in ibtoold
14 0x0000000104a448f1 (in ibtoold
15 0x0000000104a42524 (in ibtoold
16 0x000000000000000 Command /Applications/Xcode4.5SDK6.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/ibtool failed with exit code 255
Only for a XIB I'll not able to build with success...have you got the solution?
thanks!
Dario
Note: I edited this a few times as new ideas came to mind so its a bit jerky I know.
1)Look at the command line tool 'ibtool' - there is a man page - and you can try manually to translate the xib file and maybe validate it (I've not used this in years and years)
2) Other ideas (but failing those, you should burn a DTS Incident - you get 2 per year - and try to get some help from an Apple engineer):
clean your project
delete the cached data (Organizer->Projects->Derived Data tap 'Delete...'
insure that for this XIB the proper versioning is set (select XIB, 3rd Xcode tab on right, File options:
close the project
quit Xcode
reopen Xcode, then the product
try again
If this does not do it, use the DTS incident, or post on the internal Apple lists - the ones you have to login for - and maybe someone there knows of an issue
3) If you are truly desperate, make a copy of your xib file. Then start deleting objects, the easiest first, and try to build. At some point it may compile. Then re-add the other objects back.
4) If 3 does not do it, blow the xib file away, create a new one, and essentially reconstruct what you have.
EDIT: (update in comments by original poster)
5) Reboot the machine and try again.
"Clean" my project solved my problem. I'm using XCode 4.5.
The following steps work for me.
Thanks David for steps #1 to #4
Clean my project build
Delete the cached data (Organizer->Projects->Derived Data tap 'Delete...'
Close the project
Quit Xcode (I did stop at this step and tried to reopen Xcode but the error remains)
Restart my computer. (Tried to open Xcode afterwards but the same build error still happens)
Make a copy of Xcode (I put the copy at ~/Desktop)
Delete the original copy at /Applications
Put the copy of Xcode back to /Applications
Done

Resources