【发布时间】:2016-05-18 09:28:02
【问题描述】:
我尝试在 App Store 中发布应用程序,但我收到了 Apple 团队的回复,该应用程序崩溃了。我使用 Crashlytics,所以我得到了特定的崩溃线。 我无法在设备或模拟器中复制崩溃。
此代码应计算静态资源的 md5 总和,以确保没有人更改它们。
代码:
NSArray *formats = @[@"html", @"mustache", @"strings", @"p12", @"xml", @"der", @"nss", @"css", @"json", @"plist"];
NSArray *filesToSkip = @[@"Info.plist"];
NSBundle *bundle = [NSBundle mainBundle];
NSString *resourcePath = [bundle resourcePath];
NSFileManager *man = [NSFileManager defaultManager];
NSArray *resPaths = [man subpathsAtPath:resourcePath];
resPaths = [resPaths sortedArrayUsingSelector:@selector(compare:)];
NSMutableArray *sums = [NSMutableArray array];
for(NSString *path in resPaths) {
if([filesToSkip containsObject:[path lastPathComponent]] == NO && [formats containsObject:[path pathExtension]]) {
NSString *fullPath = [resourcePath stringByAppendingPathComponent:path];
NSData *content = [NSData dataWithContentsOfFile:fullPath];
NSString *md5 = [content md5];
[sums addObject:md5]; //line of crash - inserting nil element into the NSMutableArray
}
}
md5 方法如果来自这里:https://stackoverflow.com/a/16391701/5226328 - 当 NSData 对象为 nil 时返回 nil。
它试图找到问题,但我不知道发生了什么:
我找不到任何会使md5 (string) nil 的场景(即使使用 bundle == nil 或 resourcePath == nil 它也不应该在该行崩溃)。
我想我错过了一些东西(或者不了解 Apple Review 方法)。任何帮助或建议将不胜感激。
【问题讨论】:
标签: ios objective-c md5