iOS 8 - Unable to symbolicate symbols coming from

2019-08-14 02:30发布

问题:

Here is what I have: - iOS app called VacationSpots (.APP file)

  • app dSYM file

  • dynamic framework named VSUtilities (.framework file)

  • dynamic framework dSYM file

Here is the sample project source code: https://www.dropbox.com/s/nl32xlk98lnl1mv/VacationSpots.zip?dl=0

I made the app crash at launch by force unwrapping a nil optional.

Below is part of the symbolicated crash report. Notice that VSUtilities calls are not symbolicated:

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libswiftCore.dylib              0x00333470 0x1d1000 + 1451120
1   VSUtilities                     0x001c0bd8 0x1b9000 + 31704
2   VacationSpots                   0x0007a418 SpotsViewController.awakeFromNib() -> () (SpotsViewController.swift:38)
3   VacationSpots                   0x0007a4b8 @objc SpotsViewController.awakeFromNib() -> () (SpotsViewController.swift:0)
4   UIKit                           0x2940036a -[UINib instantiateWithOwner:options:] + 1910
5   UIKit                           0x29641818 -[UIStoryboard instantiateViewControllerWithIdentifier:] + 196
6   UIKit                           0x2964197a -[UIStoryboard instantiateInitialViewController] + 58
7   UIKit                           0x291f8ea0 -[UIApplication _loadMainStoryboardFileNamed:bundle:] + 84
8   UIKit                           0x28fccebc -[UIApplication _loadMainInterfaceFile] + 260
9   UIKit                           0x291f7d80 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1256
10  UIKit                           0x2920bb9c __84-[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:]_block_invoke3228 + 36
11  UIKit                           0x291f53aa -[UIApplication workspaceDidEndTransaction:] + 134
12  FrontBoardServices              0x26100c7e -[FBSSerialQueue _performNext] + 230
13  FrontBoardServices              0x26100f70 -[FBSSerialQueue _performNextFromRunLoopSource] + 48
14  CoreFoundation                  0x24ddf68e __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14
15  CoreFoundation                  0x24ddf27c __CFRunLoopDoSources0 + 452
16  CoreFoundation                  0x24ddd5ea __CFRunLoopRun + 794
17  CoreFoundation                  0x24d30bf8 CFRunLoopRunSpecific + 520
18  CoreFoundation                  0x24d309e4 CFRunLoopRunInMode + 108
19  UIKit                           0x28fc65bc -[UIApplication _run] + 524
20  UIKit                           0x28fc0ba0 UIApplicationMain + 144
21  VacationSpots                   0x00081d4c main (AppDelegate.swift:26)
22  libdyld.dylib                   0x249df872 start + 2

Here is part of the symbolicatecrash command output:

Finding Symbols:
.fetching symbol file for VSUtilities--[undef] 
Searching []...-- NO MATCH
Searching in Spotlight for dsym with UUID of 9acae8d3326233adaaea24609e951306
Running mdfind "com_apple_xcode_dsym_uuids == 9ACAE8D3-3262-33AD-AAEA-24609E951306"
Running mdls -name com_apple_xcode_dsym_paths \/Users\/maxkorytko\/Library\/Developer\/Xcode\/DerivedData\/VacationSpots\-citeoysntsbhwwfzcqytfuzhnqze\/Build\/Products\/Debug\-iphoneos\/VSUtilities\.framework\.dSYM
@dsym_paths = ( /Users/maxkorytko/Library/Developer/Xcode/DerivedData/VacationSpots-citeoysntsbhwwfzcqytfuzhnqze/Build/Products/Debug-iphoneos/VSUtilities.framework.dSYM/Contents/Resources/DWARF/VSUtilities )
@exec_names = ( VSUtilities )
Running mdfind "kMDItemContentType == com.apple.application-bundle && (kMDItemAlternateNames == 'VSUtilities.app' || kMDItemDisplayName == 'VSUtilities' || kMDItemDisplayName == 'VSUtilities.app')"
Running mdfind "kMDItemContentType == public.unix-executable && kMDItemDisplayName == 'VSUtilities'"
Did not find executable for dsym
## Warning: Can't find any unstripped binary that matches version of /var/mobile/Containers/Bundle/Application/BE14C237-9798-4030-9806-11F3386A0077/VacationSpots.app/Frameworks/VSUtilities.framework/VSUtilities

..fetching symbol file for VacationSpots--[undef] 
Searching []...-- NO MATCH
Searching in Spotlight for dsym with UUID of d2731d399b5132329532fea91df1ca19
Running mdfind "com_apple_xcode_dsym_uuids == D2731D39-9B51-3232-9532-FEA91DF1CA19"
Running mdls -name com_apple_xcode_dsym_paths \/Users\/maxkorytko\/Library\/Developer\/Xcode\/DerivedData\/VacationSpots\-citeoysntsbhwwfzcqytfuzhnqze\/Build\/Products\/Debug\-iphoneos\/VacationSpots\.app\.dSYM
@dsym_paths = ( /Users/maxkorytko/Library/Developer/Xcode/DerivedData/VacationSpots-citeoysntsbhwwfzcqytfuzhnqze/Build/Products/Debug-iphoneos/VacationSpots.app.dSYM/Contents/Resources/DWARF/VacationSpots )
@exec_names = ( VacationSpots )
Running mdfind "kMDItemContentType == com.apple.application-bundle && (kMDItemAlternateNames == 'VacationSpots.app' || kMDItemDisplayName == 'VacationSpots' || kMDItemDisplayName == 'VacationSpots.app')"
Running mdfind "kMDItemContentType == public.unix-executable && kMDItemDisplayName == 'VacationSpots'"
Running /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo -info '/Users/maxkorytko/Library/Developer/Xcode/DerivedData/VacationSpots-citeoysntsbhwwfzcqytfuzhnqze/Build/Products/Debug-iphoneos/VacationSpots.app/VacationSpots'
Running /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool -arch armv7 -l '/Users/maxkorytko/Library/Developer/Xcode/DerivedData/VacationSpots-citeoysntsbhwwfzcqytfuzhnqze/Build/Products/Debug-iphoneos/VacationSpots.app/VacationSpots'

Number of symbols in /Users/maxkorytko/Library/Developer/Xcode/DerivedData/VacationSpots-citeoysntsbhwwfzcqytfuzhnqze/Build/Products/Debug-iphoneos/VacationSpots.app/VacationSpots: 335 + 2081 = 2416
Found executable /Users/maxkorytko/Library/Developer/Xcode/DerivedData/VacationSpots-citeoysntsbhwwfzcqytfuzhnqze/Build/Products/Debug-iphoneos/VacationSpots.app/VacationSpots
-- MATCH

回答1:

Faced something similar today. There were two problems in my case:

  1. .framework inside .app would not get "indexed enough"/get all the metadata for mdfind, like kMDItemDisplayName, unless I moved it out of .app.

  2. symbolicatecrash was using mdfind with "kMDItemContentType == public.unix-executable", while the real kMDItemContentType for my framework executable was "public.data".

Solved it by:

  1. Moving .framework out of .app (in my case I moved all the stuff to Desktop, to be sure that it will be indexed correctly)

  2. Modifying (copy of) symbolicatecrash to look not only for "kMDItemContentType == public.unix-executable" but for "kMDItemContentType == public.data"

P.S. You can use mdls to get the indexed metadata attributes of a file:

MacBook-Pro-GE:~ eg$ mdls -name kMDItemContentType ~/Desktop/OPASAppKit.framework/OPASAppKit kMDItemContentType = "public.data"

As for modified version of symbolicatecrash, I'm not sure whether I can post it here as is, but here's a diff, there's just a single line that's changed.

https://gist.githubusercontent.com/grigorye/25dbfe64e6d91db21817/raw/6e33f1d77abca6ffc022bedefcd5a5f1d1bc308f/symbolicatecrash-publicdata.diff

Btw, it looks like Xcode uses symbolicatecrash for symbolicating as well, so patching the script inside Xcode allowed me to symbolicate crashes with custom dynamic frameworks there too.