Xcode升级后,iOS Project会抛出未处理的异常

时间:2015-10-12 21:07:30

标签: ios iphone xcode cordova

我正在开发一个PhoneGap应用程序。应用程序本身似乎已经处理好了iOS 9,因为它仍在运行,但是向新Xcode的过渡引入了一个新的异常,这个异常在旧版本的Xcode下没有发生。

我收到以下异常文字:

2015-10-12 13:40:58.434 <AppName>[29769:897739] -[__NSDictionaryI length]:      unrecognized selector sent to instance 0x7ff0295c95d0
2015-10-12 13:40:58.445 <AppName>[29769:897739] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryI length]: unrecognized selector sent to instance 0x7ff0295c95d0'
*** First throw call stack:
(
0   CoreFoundation                      0x000000010d24bf65 __exceptionPreprocess + 165
1   libobjc.A.dylib                     0x000000011061fdeb objc_exception_throw + 48
2   CoreFoundation                      0x000000010d25458d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3   CoreFoundation                      0x000000010d1a1f7a ___forwarding___ + 970
4   CoreFoundation                      0x000000010d1a1b28 _CF_forwarding_prep_0 + 120
5   UIKit                               0x000000010d857011 -[UILabel _ensureBaselineMetricsReturningBounds] + 153
6   UIKit                               0x000000010d85725e -[UILabel _firstBaselineOffsetFromTop] + 36
7   UIKit                               0x000000010de7d0c3 -[UIView(AdditionalLayoutSupport) nsli_lowerAttribute:intoExpression:withCoefficient:forConstraint:onBehalfOfLayoutGuide:] + 1560
8   UIKit                               0x000000010de7ca8f -[UIView(AdditionalLayoutSupport) nsli_lowerAttribute:intoExpression:withCoefficient:forConstraint:] + 74
9   Foundation                          0x00000001101f3bd8 lower_1_attribute + 158
10  Foundation                          0x00000001101f36ec -[NSLayoutConstraint _lowerIntoExpression:reportingConstantIsRounded:] + 102
11  Foundation                          0x00000001101e98f1 -[NSLayoutConstraint _addToEngine:integralizationAdjustment:mutuallyExclusiveConstraints:] + 96
12  UIKit                               0x000000010de79213 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 504
13  Foundation                          0x00000001101f723a -[NSISEngine withBehaviors:performModifications:] + 155
14  UIKit                               0x000000010de79637 -[UIView(AdditionalLayoutSupport) _withAutomaticEngineOptimizationDisabledIfEngineExists:] + 58
15  UIKit                               0x000000010de78fd3 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 646
16  UIKit                               0x000000010de79640 -[UIView(AdditionalLayoutSupport) _withAutomaticEngineOptimizationDisabledIfEngineExists:] + 67
17  UIKit                               0x000000010de78d08 -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 242
18  UIKit                               0x000000010de790fc __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 225
19  Foundation                          0x00000001101f723a -[NSISEngine withBehaviors:performModifications:] + 155
20  UIKit                               0x000000010de79637 -[UIView(AdditionalLayoutSupport) _withAutomaticEngineOptimizationDisabledIfEngineExists:] + 58
21  UIKit                               0x000000010de78fd3 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 646
22  UIKit                               0x000000010de79640 -[UIView(AdditionalLayoutSupport) _withAutomaticEngineOptimizationDisabledIfEngineExists:] + 67
23  UIKit                               0x000000010de78d08 -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 242
24  UIKit                               0x000000010d6b2fef -[UIScrollView _switchToLayoutEngine:] + 107
25  UIKit                               0x000000010de790fc __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 225
26  Foundation                          0x00000001101f723a -[NSISEngine withBehaviors:performModifications:] + 155
27  UIKit                               0x000000010de79637 -[UIView(AdditionalLayoutSupport) _withAutomaticEngineOptimizationDisabledIfEngineExists:] + 58
28  UIKit                               0x000000010de78fd3 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 646
29  UIKit                               0x000000010de79640 -[UIView(AdditionalLayoutSupport) _withAutomaticEngineOptimizationDisabledIfEngineExists:] + 67
30  UIKit                               0x000000010de78d08 -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 242
31  UIKit                               0x000000010de790fc __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 225
32  Foundation                          0x00000001101f723a -[NSISEngine withBehaviors:performModifications:] + 155
33  UIKit                               0x000000010de79637 -[UIView(AdditionalLayoutSupport) _withAutomaticEngineOptimizationDisabledIfEngineExists:] + 58
34  UIKit                               0x000000010de78fd3 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 646
35  UIKit                               0x000000010de79640 -[UIView(AdditionalLayoutSupport) _withAutomaticEngineOptimizationDisabledIfEngineExists:] + 67
36  UIKit                               0x000000010de78d08 -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 242
37  UIKit                               0x000000010de790fc __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 225
38  Foundation                          0x00000001101f723a -[NSISEngine withBehaviors:performModifications:] + 155
39  UIKit                               0x000000010de79637 -[UIView(AdditionalLayoutSupport) _withAutomaticEngineOptimizationDisabledIfEngineExists:] + 58
40  UIKit                               0x000000010de78fd3 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 646
41  UIKit                               0x000000010de79640 -[UIView(AdditionalLayoutSupport) _withAutomaticEngineOptimizationDisabledIfEngineExists:] + 67
42  UIKit                               0x000000010de78d08 -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 242
43  UIKit                               0x000000010de790fc __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 225
44  Foundation                          0x00000001101f723a -[NSISEngine withBehaviors:performModifications:] + 155
45  UIKit                               0x000000010de79637 -[UIView(AdditionalLayoutSupport) _withAutomaticEngineOptimizationDisabledIfEngineExists:] + 58
46  UIKit                               0x000000010de78fd3 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 646
47  UIKit                               0x000000010de79640 -[UIView(AdditionalLayoutSupport) _withAutomaticEngineOptimizationDisabledIfEngineExists:] + 67
48  UIKit                               0x000000010de78d08 -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 242
49  UIKit                               0x000000010d6980dc __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 113
50  Foundation                          0x00000001101f723a -[NSISEngine withBehaviors:performModifications:] + 155
51  UIKit                               0x000000010d698024 -[UIView(Hierarchy) _postMovedFromSuperview:] + 575
52  UIKit                               0x000000010d6a5ac3 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1967
53  UIKit                               0x000000010d8e7695 -[_UIAlertControllerPresentationController presentationTransitionWillBegin] + 208
54  UIKit                               0x000000010d75999c __71-[UIPresentationController _initViewHierarchyForPresentationSuperview:]_block_invoke + 2044
55  UIKit                               0x000000010d7575c5 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 309
56  UIKit                               0x000000010d6044be _runAfterCACommitDeferredBlocks + 317
57  UIKit                               0x000000010d6167ee _cleanUpAfterCAFlushAndRunDeferredBlocks + 95
58  UIKit                               0x000000010d6224e6 _afterCACommitHandler + 90
59  CoreFoundation                      0x000000010d1779d7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
60  CoreFoundation                      0x000000010d177947 __CFRunLoopDoObservers + 391
61  CoreFoundation                      0x000000010d16d59b __CFRunLoopRun + 1147
62  CoreFoundation                      0x000000010d16ce98 CFRunLoopRunSpecific + 488
63  GraphicsServices                    0x0000000111d12ad2 GSEventRunModal + 161
64  UIKit                               0x000000010d5f8676 UIApplicationMain + 171
65  <AppName>                          0x000000010cd9c061 main + 65
66  libdyld.dylib                       0x0000000110ff192d start + 1
67  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

查看代码,它显示以下内容作为异常的来源:

int main(int argc, char* argv[])
{
    @autoreleasepool {
        int retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate");
        return retVal;
    }       
}

来自UIApplicationMain()电话的例外情况。继堆栈跟踪之后,我将进入汇编代码,这似乎是Apple库。

我基本上确定代码问题与UIApplicationMain()调用直接无关,并且可能是项目文件中的其他内容已被破坏,但我无法获得跟踪为了我的生命,这个错误。

如果我在Xcode 6.0或6.3(我尝试过的其他两个版本)中加载同一个项目,则此时不会抛出任何异常。即使是在iOS 9中测试的商店中已编译的应用程序似乎也没有这个问题。到目前为止,只有通过Xcode 7.0在调试模式下运行应用程序时才会出现问题。

Config.xml指定使用phonegap-version 3.5来构建它,但我已经尝试过最新版本的其他版本,并且所有版本都有这个问题。

我一直试图解决这个问题两天了,但我没有取得任何进展,因为我无法掌握可能出错的问题。我最终检查的一切似乎都很好,但这个错误从某个地方出现。我觉得这必须是某个地方配置错误的情况,所以它在Apple的代码中爆炸,无论错误配置的部分最终被使用,但我完全不知道什么。我很难过。有没有人有任何有用的信息可以帮助我?

更新:我终于找到了它。隐藏在调试输出中的是我忽略的一条线:

 NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802

这导致我this question here on SO。事实证明,这是我问题的根本原因。这也解释了为什么应用程序在实际设备上的生产工作正常,以及为什么旧的Xcode很好。正在进行的Web请求是针对生产中的HTTPS进行的,但是用于开发的服务器是HTTP。因此,应用程序的生产版本很好,应用程序的开发版本在旧的Xcode(没有ATS)中很好,但针对新的iOS 9 Xcode编译的应用程序的开发版本抛出异常。

我正忙着查看调试输出中的大异常和其他一些主要项目,我错过了隐藏在其他项目之间的关键线。

1 个答案:

答案 0 :(得分:3)

  

向新Xcode的过渡引入了新的异常

新版本的Xcode通常带有新的框架。并不是说Xcode本身导致了异常,而是之前允许你的代码执行的操作,但在最新版本的框架中引发异常。

从堆栈跟踪中可以清楚地看到,在自动布局系统正在执行其操作时发生异常。查看您的故事板,看看是否有任何需要解决的布局问题。另外,请查看控制台上的消息 - 通常有一条线索可以解释导致异常的原因。