从 AppStore 或 TestFlight 启动时应用程序崩溃,但在其他方面工作正常

Posted

技术标签:

【中文标题】从 AppStore 或 TestFlight 启动时应用程序崩溃,但在其他方面工作正常【英文标题】:App crashing when launching from AppStore or TestFlight but working fine elseways 【发布时间】:2017-02-08 21:08:49 【问题描述】:

我的应用程序更新已被拒绝。在拒绝消息中,他们写了“应用程序在启动时崩溃”。然后我尝试了我的应用程序,但无法让它崩溃。所以我使用了 TestFlight 并注意到当我从 TestFlight 或 AppStore 启动我的应用程序时,它在启动时崩溃了。但是,如果我正常启动我的应用程序,它确实可以正常工作而不会发生任何崩溃。问题是自从 ios 10 更新以来就发生了这个错误。现在,我在商店中的应用程序在从 AppStore 启动时也会崩溃,而 2 周后它运行良好。

Apple 向我发送了崩溃日志:

Incident Identifier: 001969F1-F275-4AC3-AFE1-E0426957B702
CrashReporter Key:   5ad9695e945a7d5eb5d61fd18d1c3989ccd155b4
Hardware Model:      xxx
Process:             MyApp [400]
Path:                /private/var/containers/Bundle/Application/644423A4-EFE7-41B1-99D9-47B46338A6E2/MyApp.app/MyApp
Identifier:          com.MyApp.com
Version:             20160527 (2.7.9)
Code Type:           ARM-64 (Native)
Role:                Foreground
Parent Process:      launchd [1]
Coalition:           com.MyApp.com [451]


Date/Time:           2016-09-22 11:19:22.6893 -0700
Launch Time:         2016-09-22 11:19:22.4164 -0700
OS Version:          iPhone OS 10.0.1 (14A403)
Report Version:      104

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x000000010008a864
Termination Signal: Trace/BPT trap: 5
Termination Reason: Namespace SIGNAL, Code 0x5
Terminating Process: exc handler [0]
Triggered by Thread:  0

Filtered syslog:
None found

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0  MyApp                         0x1000efd3c specialized AppDelegate.application(UIApplication, didFinishLaunchingWithOptions : [NSObject : AnyObject]?) -> Bool (AppDelegate.swift:218)
1  MyApp                         0x1000ed310 @objc AppDelegate.application(UIApplication, didFinishLaunchingWithOptions : [NSObject : AnyObject]?) -> Bool (AppDelegate.swift)
2  UIKit                          0x19888c42c <redacted> + 400
3  UIKit                          0x198a9cb70 <redacted> + 3524
4  UIKit                          0x198aa28e0 <redacted> + 1656
5  UIKit                          0x198ab7080 <redacted> + 48
6  UIKit                          0x198a9f8c4 <redacted> + 168
7  FrontBoardServices             0x1945798bc <redacted> + 36
8  FrontBoardServices             0x194579728 <redacted> + 176
9  FrontBoardServices             0x194579ad0 <redacted> + 56
10 CoreFoundation                 0x192986278 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
11 CoreFoundation                 0x192985bc0 __CFRunLoopDoSources0 + 524
12 CoreFoundation                 0x1929837c0 __CFRunLoopRun + 804
13 CoreFoundation                 0x1928b2048 CFRunLoopRunSpecific + 444
14 UIKit                          0x1988855dc <redacted> + 608
15 UIKit                          0x198880360 UIApplicationMain + 208
16 MyApp                         0x1000ee818 main (AppDelegate.swift:58)
17 libdispatch.dylib              0x1918945b8 (Missing)

还有 4 个其他线程,但这个是崩溃的,所以我没有复制其余的。我做了一些研究,尽管我确实注意到我的崩溃日志没有完全翻译(出于某种奇怪的原因,因为我有所有的 dsym,但无论如何),我确实设法理解我在第 217 行崩溃了(告诉我如果我'我错了)。我知道 SIGTRAP 大部分时间都是抛出 NSExceptions。该行本身是:

let api = MyAppAPI.instance

实例是单例。我的猜测是实例创建中的某些内容失败了。代码如下:

static var instance: MyAppAPI = 
    return Singleton.instance
()

class MyAppAPI: Manager 
struct Singleton 
    static var configuration: NSURLSessionConfiguration = 
        var configuration = NSURLSessionConfiguration.defaultSessionConfiguration()
        let version = NSBundle.mainBundle().objectForInfoDictionaryKey("CFBundleShortVersionString") as? String ?? ""
        configuration.HTTPAdditionalHeaders = [
            "Accept": "application/vnd.MyApp.api+json, application/json;q=0.9",
            "User-Agent": "MyApp iOS/\(version)",
            "X-API-Version": "1.0.1"
        ]

        return configuration
        ()

    static var instance = MyAppAPI(configuration: configuration)
    static var baseURL : NSURL! = nil

我对这个错误非常绝望,我确实尝试了一些没有成功的方法。我在寻找正确的地方吗?有没有人有解决方案?任何形式的帮助将不胜感激。我愿意赠送任何可以找到我解决方案或帮助我找到解决方案的人!

【问题讨论】:

崩溃报告需要符号化。 从 appdelegate 添加 altert start 到其他 Viewcontrollers 你会发现问题 我会尝试其他视图的替代推送,谢谢。关于象征性,我确实在问题中写了一些关于它的内容,并且我已经翻译了一半的崩溃报告。由于崩溃的部分已经翻译,我是否需要翻译所有内容? 布莱恩,你找到答案了吗?我也有同样的问题,谢谢! 对我来说是fatal error: unexpectedly found nil while unwrapping an Optional value 【参考方案1】:

我找到了我的问题的解决方案。

不出所料,它来自func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -&gt; Bool

在我拥有let userInfo = launchOpts[UIApplicationLaunchOptionsRemoteNotificationKey] as! NSDictionary 的函数内部。

我将其更改为let userInfo = launchOpts[UIApplicationLaunchOptionsRemoteNotificationKey] as? NSDictionary,然后检查if userInfo != nil,使所有运行userInfo的代码放入括号中。

如果它对任何人有帮助,或者如果有人在这个问题上苦苦挣扎,请检查你所有的 ! 并在需要时将它们交换为 ?(在 didFinishLaunchingWithOptions 上),因为从 TestFlight/AppStore 启动似乎有不同的选项而不是从已安装的应用程序(只是猜测,不够专业,无法声明)。

【讨论】:

你是怎么发现是这种情况,因为你不能调试它?您是否将设备崩溃日志/崩溃报告工具隔离到 # this was called on 行? 如果我没记错的话,我确实通过 AlertView 进行了调试。我在特定点打印了日志,这有助于我调试! 这是我整个星期读过的最好的东西,谢谢 嗨,布莱恩,我从苹果方面得到了相同的崩溃日志。你能帮我看看我将如何得到一个正确的错误。请指导我。提前致谢。 AppDelegate 上的 didFinishLaunchingWithOptions 导致崩溃?

以上是关于从 AppStore 或 TestFlight 启动时应用程序崩溃,但在其他方面工作正常的主要内容,如果未能解决你的问题,请参考以下文章

iOS TestFlight 构建更新到 AppStore 构建

从 TestFlight beta 应用程序更新应用程序到 AppStore 列出的应用程序

AppStore 与 TestFlight 的按需资源下载速度

在 AppStore 审核之前删除 Apple TestFlight 测试版权利?

iOS 应用的 AppStore 版本及其多个 Testflight 构建在同一设备上

具有相同证书的 AppStore 和 Testflight