由于没有堆栈跟踪的未捕获异常,iOS App终止(Swift)

时间:2016-07-04 17:53:42

标签: ios swift

我正在为我的应用中的UI元素编写动画代码。应用程序工作正常,直到我在某些UI元素上更改了alpha,当我收到此错误时:

libc++abi.dylib: terminating with uncaught exception of type NSException

没有堆栈跟踪或指示错误可能在输出中的位置,只是指向AppDelegate类的Signal SIGABRT。

该应用程序在上一个版本中工作,之后我更改了所有的alpha设置,我将其解除尝试并调试情况。我已经尝试禁用我最近修改的代码的某些部分,例如Game Center,我尝试设置断点但无法使应用程序正常工作。

我的问题 - 这是什么错误,它来自哪里?

如果您需要查看,我最近修改了一些代码:

//This code is called in a Game Center Authentication method
         UIView.animate(withDuration: 0.5, animations: {
                        self.pointsIndicator.center.x += self.view.bounds.width
                       // self.pointsIndicator.alpha = 1
                    })
                    UIView.animate(withDuration: 0.5, delay: 0.3, options: [], animations: {
                        self.pointsLabel.center.x += self.view.bounds.width
                       // self.pointsLabel.alpha = 1
                        }, completion: nil)

查看将出现:

override func viewWillAppear(_ animated: Bool) {

    //Setup animations
    print("\(progBar.center.x) Before")
    pointsIndicator.center.x  -= view.bounds.width
    pointsLabel.center.x -= view.bounds.width
    progBar.center.x -= view.bounds.width
    masterLabel.center.x -= view.bounds.width

    pointsIndicator.alpha = 0
    pointsLabel.alpha = 0
    progBar.alpha = 0
    masterLabel.alpha = 0

}

更新 我在调试器上运行了bt命令。这是输出:

* thread #1: tid = 0x6646da, 0x0000000110607e6e libsystem_kernel.dylib`__pthread_kill + 10, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
frame #0: 0x0000000110607e6e libsystem_kernel.dylib`__pthread_kill + 10
frame #1: 0x000000011063e8fb libsystem_pthread.dylib`pthread_kill + 90
frame #2: 0x00000001103570b3 libsystem_c.dylib`abort + 129
frame #3: 0x000000010fe6243a libc++abi.dylib`abort_message + 266
frame #4: 0x000000010fe86a9f libc++abi.dylib`default_terminate_handler() + 267
frame #5: 0x000000010985359f libobjc.A.dylib`_objc_terminate() + 103
frame #6: 0x000000010fe83c09 libc++abi.dylib`std::__terminate(void (*)()) + 8
frame #7: 0x000000010fe83894 libc++abi.dylib`__cxa_rethrow + 99
frame #8: 0x00000001098534b7 libobjc.A.dylib`objc_exception_rethrow +  40
frame #9: 0x0000000106c07bf1 CoreFoundation`CFRunLoopRunSpecific + 433
frame #10: 0x0000000107d4ac00 UIKit`-[UIApplication _run] + 459
frame #11: 0x0000000107d50e8b UIKit`UIApplicationMain + 159
* frame #12: 0x000000010681423f MathsRobot LearnMaths`main + 111 at     AppDelegate.swift:19
frame #13: 0x00000001102ab6bd libdyld.dylib`start + 1
frame #14: 0x00000001102ab6bd libdyld.dylib`start + 1

更新:AppDelegate:19

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

1 个答案:

答案 0 :(得分:9)

Apple forums上归功于jeromeshr。使用来自Swift代码的Cocoapod调用的一些Objective-C代码进入了这个问题。如果将OS_ACTIVITY_MODE标志设置为环境变量,则会阻止显示正确的堆栈跟踪。它设置在我的所有应用程序上,以避免控制台中无休止的无用信息流。在调试时,只需取消选中它旁边的框(您不必删除它)。