Application error when starting from AppStore or TestFlight, but it works fine

My app update was rejected. In the rejection message, they wrote "Application crash on startup." Then I tried my application, but could not cope with it. So I used TestFlight and noticed that when I started my application from TestFlight or AppStore, it started at startup. But if I run my application in normal mode, it works without crashing. The fact is that this error has occurred since the iOS 10 update. Now my application in the store also crashes when launched from the AppStore, while it works normally for 2 weeks.

Apple sent me a crash log:

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) 

There are 4 more topics, but this is one of them, so I did not copy the rest. I did some research, and although I noticed that my crash log was not completely translated (for some strange reason, since I have all the dsyms, but anything), I was able to understand that I was crashing on line 217 ( tell me wrong). I know that SIGTRAP in most cases is thrown by NSExceptions. The string itself:

 let api = MyAppAPI.instance 

Instance is singleton. I suppose something in instantiation fails. Here is the code:

 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 } 

I am so desperately worried about this error, I tried several things that did not work. Am I looking for a suitable place? Is there anyone with a solution? Any help would be greatly appreciated. I am ready to give to anyone who finds a solution for me or helps me find a solution!

+5
source share
1 answer

I found a solution to my problem.

As expected, it came from a func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool

Inside the function, I had let userInfo = launchOpts[UIApplicationLaunchOptionsRemoteNotificationKey] as! NSDictionary let userInfo = launchOpts[UIApplicationLaunchOptionsRemoteNotificationKey] as! NSDictionary .

I changed it to let userInfo = launchOpts[UIApplicationLaunchOptionsRemoteNotificationKey] as? NSDictionary let userInfo = launchOpts[UIApplicationLaunchOptionsRemoteNotificationKey] as? NSDictionary , and then checked if userInfo != nil to make all the code with userInfo in userInfo .

If this helps someone or someone is struggling with this problem, check all of yours ! and replace them with ? if necessary (at didFinishLaunchingWithOptions ), since starting from TestFlight / AppStore seems to be different from the parameters (just a hunch, not enough to state it).

+4
source

Source: https://habr.com/ru/post/1257509/


All Articles