ios6 - libMobileGestalt copySystemVersionDictionaryValue : Could not lookup ReleaseType from system version dictionary

标签 ios6 crash-reports core-text core-foundation

在提交更新之前,我一直在测试......来自 iOS4,并且遇到了以下问题...... 1)从我的应用程序创建 PDF。 2) 似乎不一致,因为在大多数情况下我可以毫无问题地创建新的 PDF。 3) 崩溃日志表明在 ExportView 的第 341 行发生了崩溃,我已对其进行了配置,因此该行上唯一的项目是 CFRangeMake。请注意,在控制台中有一个值,因为在多行中使用了相同的值。

一些注意事项:使用 Xcode 4.6,目标是 iOS6,完全 ARC,在新 iPad 上测试。

对此的任何帮助将不胜感激!!

我删除了一些崩溃日志和控制台日志以缩短这篇文章!即使现在也为它的长度道歉!

将字符串应用于 PDF 创建的方法:

- (CFMutableAttributedStringRef) CreateAttributedString:(int*) dateLength
                                        titleLength:(int*) titleLength
{
    NSLog(@"Current EntryIndex: %d", _entryIndex);
    NSLog(@"Current Entry: %@", _currentEntry); // current entry is set from the parent view controller via PrepareForSegue

    NSDateFormatter * dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"MMMM dd, yyyy, h:mm aaa"];
    NSString * dateString = [dateFormatter stringFromDate:_currentEntry.created];
    *dateLength = [dateString length];
    NSLog(@"DateString: %@", dateString);
    NSLog(@"2nd DateLength: %d", *dateLength);

    NSString *title = _entryTitle;
    *titleLength = [title length];

    NSString *bodyString = _entryText;
    NSString *contentString = [NSString stringWithFormat:@"%@\n\n%@\n%@", dateString, title, bodyString];
    NSLog(@"TitleString: %@", title);
    NSLog(@"BodyString: %@", bodyString);
    NSLog(@"TitleLength: %d", *titleLength);

    CFStringRef string = (__bridge CFStringRef)contentString;
    CFMutableAttributedStringRef attributedContentString  CFAttributedStringCreateMutable(kCFAllocatorDefault, 0);
    CFAttributedStringReplaceString (attributedContentString,CFRangeMake(0, 0), string);
    return  attributedContentString;
    }

 - (void) SetTextFontName:(int)dateLength titleLength:(int)titleLength forAttributedString:(CFMutableAttributedStringRef) text
{
    //date
    CTFontDescriptorRef dateFontDescriptor = CTFontDescriptorCreateWithNameAndSize((__bridge CFStringRef)_entryDateTimeFontName, _entryDateTimeFontSize);

    CTFontRef dateFont = CTFontCreateWithFontDescriptor(dateFontDescriptor, _entryDateTimeFontSize, NULL);
    NSLog(@"Font entryDateTimeFontSize, line 329: %d", _entryDateTimeFontSize);
    NSLog(@"DateFontDescriptor, line 329: %@", dateFontDescriptor);
    CFAttributedStringSetAttribute(text, CFRangeMake(0, dateLength), kCTFontAttributeName, dateFont);
    NSLog(@"DateLength... before crash: %d", dateLength);
    NSLog(@"DateLength... crashing: %d", dateLength);
    CFAttributedStringSetAttribute(text,
                               CFRangeMake(0, dateLength),    // this is line 341...
                               kCTForegroundColorAttributeName,
                               _entryDateTimeColor.CGColor);
    NSLog(@"Date length for line 332: %d", dateLength);
    NSLog(@"Text for line 332: %@", text);
    NSLog(@"Font name... font attributes line 332: %@", dateFont);
    NSLog(@"Date length for line 333: %d", dateLength);
    NSLog(@"Text for line 333: %@", text);
    NSLog(@"Date color for line 333: %@", _entryDateTimeColor.CGColor);
    CFRelease(dateFontDescriptor);
    CFRelease(dateFont);

    //title
    CTTextAlignment alignment = kCTCenterTextAlignment;
    CTParagraphStyleSetting _settings[] = {{kCTParagraphStyleSpecifierAlignment, sizeof(alignment), &alignment}};
    CTParagraphStyleRef paragraphStyle = CTParagraphStyleCreate(_settings, sizeof(_settings) / sizeof(_settings[0]));
    CFAttributedStringSetAttribute(text, CFRangeMake(dateLength, dateLength + titleLength), kCTParagraphStyleAttributeName, paragraphStyle);

    CTFontDescriptorRef titleFontDescriptor = CTFontDescriptorCreateWithNameAndSize((__bridge CFStringRef)_entryTitleFontName, _entryTitleFontSize);

    CTFontRef titleFont = CTFontCreateWithFontDescriptor(titleFontDescriptor,_entryTitleFontSize, NULL);
    NSLog(@"TitleFontDescriptor: %@", titleFontDescriptor);
    CFAttributedStringSetAttribute(text, CFRangeMake(dateLength, dateLength + titleLength), kCTFontAttributeName, titleFont);
    CFAttributedStringSetAttribute(text, CFRangeMake(dateLength, dateLength + titleLength), kCTForegroundColorAttributeName, _entryTitleColor.CGColor);
    NSLog(@"TitleColor: %@", _entryTitleColor);
    NSLog(@"Titlecolor: %@", _entryTitleColor.CGColor);
    CFRelease(titleFontDescriptor);
    CFRelease(titleFont);

    //content
    CTFontDescriptorRef fontDescriptor = CTFontDescriptorCreateWithNameAndSize((__bridge CFStringRef)_entryTextFontName, _entryTextFontSize);
    CTFontRef font = CTFontCreateWithFontDescriptor(fontDescriptor, _entryTextFontSize, NULL);
    CFAttributedStringSetAttribute(text, CFRangeMake(dateLength + titleLength+2, CFAttributedStringGetLength(text) - dateLength - titleLength - 2), kCTFontAttributeName, font);
    CFAttributedStringSetAttribute(text, CFRangeMake(dateLength + titleLength+2, CFAttributedStringGetLength(text) - dateLength - titleLength - 2), kCTForegroundColorAttributeName, _entryTextColor.CGColor);
    CFRelease(fontDescriptor);
    CFRelease(font);
}

崩溃日志:
Incident Identifier: D5D15E15-8A4C-4850-B751-9F1D546F1F71
CrashReporter Key:   54bfdcf0248d463bc97ac986b7553405b3b0f8b9
Hardware Model:      iPad3,4
Process:         TabletJournal [9876]
Path:            /var/mobile/Applications/109DCB8E-22D1-45E4-A347- 1B1F211F9044/TabletJournal.app/TabletJournal
Identifier:      TabletJournal
Version:         ??? (???)
Code Type:       ARM (Native)
Parent Process:  launchd [1]

Date/Time:       2013-03-20 15:42:11.412 +0100
OS Version:      iOS 6.1.2 (10B146)
Report Version:  104

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x000000000000defe
Crashed Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   CoreFoundation                0x3272b4e0 0x32693000 + 623840
1   CoreFoundation                0x3271bc2c 0x32693000 + 560172
2   CoreFoundation                0x3277043c 0x32693000 + 906300
3   CoreFoundation                0x32697b4e 0x32693000 + 19278
4   CoreFoundation                0x32705e5e 0x32693000 + 470622
5   TabletJournal                 0x0005f3d8 -[ExportView SetTextFontName:titleLength:forAttributedString:] (ExportView.m:341)
6   TabletJournal                 0x0005ed58 -[ExportView saveJournalToPDF:andName:] (ExportView.m:196)
7   TabletJournal                 0x0005ec8a -[ExportView pdfButtonTapped:] (ExportView.m:179)
8   UIKit                         0x3464f082 0x34561000 + 974978
9   UIKit                         0x3464f036 0x34561000 + 974902
10  UIKit                         0x3464f010 0x34561000 + 974864
11  UIKit                         0x3464e8c6 0x34561000 + 972998
12  UIKit                         0x3464edb4 0x34561000 + 974260
13  UIKit                         0x345775f4 0x34561000 + 91636
14  UIKit                         0x345648dc 0x34561000 + 14556
15  UIKit                         0x345641ea 0x34561000 + 12778
16  GraphicsServices              0x362575f4 0x36251000 + 26100
17  GraphicsServices              0x36257222 0x36251000 + 25122
18  CoreFoundation                0x3272a3e4 0x32693000 + 619492
19  CoreFoundation                0x3272a386 0x32693000 + 619398
20  CoreFoundation                0x3272920a 0x32693000 + 614922
21  CoreFoundation                0x3269c238 0x32693000 + 37432
22  CoreFoundation                0x3269c0c4 0x32693000 + 37060
23  GraphicsServices              0x36256336 0x36251000 + 21302
24  UIKit                         0x345b82b4 0x34561000 + 357044
25  TabletJournal                 0x0002e35a main (main.m:22)
26  libdyld.dylib                 0x3aa02b1c 0x3aa01000 + 6940

Thread 0 crashed with ARM Thread State (32-bit):
    r0: 0x3ac440f0    r1: 0x00000000      r2: 0x00001200      r3: 0x3ac2ce44
    r4: 0x00000000    r5: 0x1ea52580      r6: 0x3272b4d9      r7: 0x2fdd26c4
    r8: 0x3ac47940    r9: 0x00000012     r10: 0x3acacd88     r11: 0x1ea52580
    ip: 0x00010201    sp: 0x2fdd26c0      lr: 0x3271bc2f      pc: 0x3272b4e0
  cpsr: 0xa0000030

控制台日志...重要部分:
Mar 20 15:50:54 Marcs-iPad TabletJournal[9947] <Warning>: SettingsModel, entries: (
"<JournalEntry: 0x1e296310>",
"<JournalEntry: 0x1e24be00>")
Mar 20 15:50:54 Marcs-iPad TabletJournal[9947] <Warning>: Export Loading
Mar 20 15:50:55 Marcs-iPad TabletJournal[9947] <Warning>: Current EntryIndex: 1
Mar 20 15:50:55 Marcs-iPad TabletJournal[9947] <Warning>: Current Entry: <JournalEntry: 0x1e296310>
Mar 20 15:50:55 Marcs-iPad TabletJournal[9947] <Warning>: DateString: marzo 20, 2013, 3:41 PM
Mar 20 15:50:55 Marcs-iPad TabletJournal[9947] <Warning>: 2nd DateLength: 23
Mar 20 15:50:55 Marcs-iPad TabletJournal[9947] <Warning>: TitleString: Test2
Mar 20 15:50:55 Marcs-iPad TabletJournal[9947] <Warning>: BodyString: I’m here in the Istanbul airport again, for another 5-hour layover! Plane is suppose to take off at 2:50 pm! Next time, I’m going to make sure my layovers are not more than 2 hours. That’ll leave room for delays. I ate a small pizza at this “Italian” diner. It was actually pretty good. Later, I’ll have to compare it with real Italian pizza. I’m dead tired. Gotta get some caffeine! Got the caffeine! Yow! I should wake up in a few minutes! There are posters of Italia here and I’ve found a couple of places I’d like to see. Lago D’Orta di Piemonte, Galleria Borghese di Lazio- Roma, Pisa.
Mar 20 15:50:55 Marcs-iPad TabletJournal[9947] <Warning>: TitleLength: 5
Mar 20 15:50:55 Marcs-iPad TabletJournal[9947] <Warning>: Font entryDateTimeFontSize, line 329: 13
Mar 20 15:50:55 Marcs-iPad TabletJournal[9947] <Warning>: DateFontDescriptor, line 329:     
CTFontDescriptor <attributes: <CFBasicHash 0x1d518f50 [0x3ac440f0]>{type = mutable dict, count = 2,
entries =>
1 : <CFString 0x3acad758 [0x3ac440f0]>{contents = "NSFontNameAttribute"} = <CFString 0x1e07a880 [0x3ac440f0]>{contents = "Copperplate"}
2 : <CFString 0x3acad8c8 [0x3ac440f0]>{contents = "NSFontSizeAttribute"} = <CFNumber 0x1d5cb1d0 [0x3ac440f0]>{value = +13.0000000000, type = kCFNumberFloat32Type}}
>
Mar 20 15:50:55 Marcs-iPad TabletJournal[9947] <Warning>: DateLength... before crash: 23
Mar 20 15:50:55 Marcs-iPad TabletJournal[9947] <Warning>: DateLength... crashing: 23
Mar 20 15:50:56 Marcs-iPad ReportCrash[9951] <Notice>: Formulating crash report for process TabletJournal[9947]
Mar 20 15:50:56 Marcs-iPad com.apple.launchd[1] (UIKitApplication:com.creativeappgroup.TabletJournalTM[0xe437][9947]) <Warning>: (UIKitApplication:com.creativeappgroup.TabletJournalTM[0xe437]) Job appears to have crashed: Trace/BPT trap: 5
Mar 20 15:50:56 Marcs-iPad ReportCrash[9951] <Error>: libMobileGestalt copySystemVersionDictionaryValue: Could not lookup ReleaseType from system version dictionary
Mar 20 15:50:56 Marcs-iPad backboardd[25] <Warning>: Application 'UIKitApplication:com.creativeappgroup.TabletJournalTM[0xe437]' exited abnormally with signal 5: Trace/BPT trap: 5
Mar 20 15:50:56 Marcs-iPad ReportCrash[9951] <Notice>: Saved crashreport to /var/mobile/Library/Logs/CrashReporter/TabletJournal_2013-03-20-155055_Marcs-iPad.plist using uid: 0 gid: 0, synthetic_euid: 501 egid: 0

最佳答案

事实证明,libModileGestalt 与崩溃无关。通过 Apple 论坛上的提示发现 CGColor 可能为零。在实际调用之前隔离并安装日志语句后,情况确实如此。事实上,所有的颜色……文本、标题和日期都变成了 NULL。因此,我通过在 create PDF 方法中安装测试和应用语句来停止崩溃。现在......找出为什么颜色没有被忽略!

关于ios6 - libMobileGestalt copySystemVersionDictionaryValue : Could not lookup ReleaseType from system version dictionary,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15528283/

相关文章:

objective-c - 创建自定义 UITableViewCell

ios - 如何让文字环绕图像

ios - 向图像添加多行文本区域

ios - iOS 6 上的低功耗蓝牙; CBPeripheralManagerDelegate

ios - 如何重新加载 UIView?

ios - 想在服务器上保存申请状态

ios - 未知的线程因未知的味道而崩溃

ios - 我可以在我的 iOS 应用程序中禁用 iTunes Connect 崩溃报告吗?

java - Android java.lang.RuntimeException : Unable to instantiate activity ComponentInfo com. aksitrewari.gateexampreparation.MyActivity

ios - 如何在 iOS 中呈现大尺寸文档?