2016-04-05 16 views
2

私はiOSプロジェクトを持っていて、デバッグモードでは全くクラッシュしません。 TestFlightにアプリをリリースするときに、私はTestflightインターフェース(開いているボタンで)からアプリを起動するとクラッシュします。Testflightから起動するとアプリケーションがクラッシュする開くボタン

iPhoneのホーム画面からアプリを起動するとクラッシュしません。

Thread : Crashed: com.apple.main-thread 
0 AppName       0x100316b8c specialized AppDelegate.application(UIApplication, didFinishLaunchingWithOptions : [NSObject : AnyObject]?) -> Bool (AppDelegate.swift) 
1 AppName       0x100314284 @objc AppDelegate.application(UIApplication, didFinishLaunchingWithOptions : [NSObject : AnyObject]?) -> Bool (AppDelegate.swift) 
2 UIKit       0x1863428a8 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 400 
3 UIKit       0x186572094 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 2904 
4 UIKit       0x186576500 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1684 
5 UIKit       0x186573674 -[UIApplication workspaceDidEndTransaction:] + 168 
6 FrontBoardServices    0x182b237ac __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 36 
7 FrontBoardServices    0x182b23618 -[FBSSerialQueue _performNext] + 168 
8 FrontBoardServices    0x182b239c8 -[FBSSerialQueue _performNextFromRunLoopSource] + 56 
9 CoreFoundation     0x181139124 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24 
10 CoreFoundation     0x181138bb8 __CFRunLoopDoSources0 + 540 
11 CoreFoundation     0x1811368b8 __CFRunLoopRun + 724 
12 CoreFoundation     0x181060d10 CFRunLoopRunSpecific + 384 
13 UIKit       0x18633b834 -[UIApplication _run] + 460 
14 UIKit       0x186335f70 UIApplicationMain + 204 
15 AppName       0x100316388 main (AppDelegate.swift:18) 
16 libdispatch.dylib    0x180bfe8b8 (Missing) 

EDIT

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 
    // Override point for customization after application launch. 
    Fabric.with([Crashlytics.self]) 
    log.xcodeColorsEnabled = true 
    let dateFormatter = NSDateFormatter() 
    dateFormatter.dateFormat = "HH:mm:ss.SSS" 
    dateFormatter.locale = NSLocale.currentLocale() 
    log.dateFormatter = dateFormatter 
    #if DEBUG 
     log.setup(.Debug, showLogIdentifier: false, showFunctionName: true, showThreadName: true, showLogLevel: true, showFileNames: true, showLineNumbers: true, showDate: true, writeToFile: nil, fileLogLevel: nil) 
    #else 
     log.setup(.Severe, showThreadName: true, showLogLevel: true, showFileNames: true, showLineNumbers: true, writeToFile: nil) 
     if let consoleLog = log.logDestination(XCGLogger.Constants.baseConsoleLogDestinationIdentifier) as? XCGConsoleLogDestination { 
     consoleLog.logQueue = XCGLogger.logQueue 
     } 
    #endif 

    application.applicationIconBadgeNumber = 0 

    NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(AppDelegate.mergeChanges(_:)), name: NSManagedObjectContextDidSaveNotification, object: nil) 

    //MARK: - Notifications registration 
    remoteToken() 

    if let launchOpts = launchOptions { 
     let remoteNotification = launchOpts[UIApplicationLaunchOptionsRemoteNotificationKey] as! NSDictionary 
     if let notifFrom = remoteNotification["from"] as? Int, notifType = remoteNotification["type"] as? Int { 
     let userid = notifFrom 
     let type = notifType 
     if type != MessageType.NotifyMsgType.rawValue { 
      loadingChatUserId = userid 
     }else{ 
      loadingChatUserId = nil 
     } 
     } 
    }else{ 
     loadingChatUserId = nil 
    } 

    return true 
    } 

func remoteToken() { 
    if UIApplication.sharedApplication().isRegisteredForRemoteNotifications() { 
     //iOS 8 notifications 
     UIApplication.sharedApplication().registerUserNotificationSettings(UIUserNotificationSettings(forTypes: [UIUserNotificationType.Sound, .Alert, .Badge], categories: nil)) 
     UIApplication.sharedApplication().registerForRemoteNotifications() 
    } 
    } 
+0

チェックあなたは...たぶんファイルを投稿したくないAppDelegateでいくつかのコードを持っているかもしれません –

+0

プロジェクトで、このlibdispatch.dylibファイル? – aramusss

+0

良いアイデア、didLaunchingWithOptionデリゲートを投稿しました – Mikael

答えて

2
if let launchOpts = launchOptions { 
    let remoteNotification = launchOpts[UIApplicationLaunchOptionsRemoteNotificationKey] as! NSDictionary 
    if let notifFrom = remoteNotification["from"] as? Int, notifType = remoteNotification["type"] as? Int { 
    let userid = notifFrom 
    let type = notifType 
    if type != MessageType.NotifyMsgType.rawValue { 
     loadingChatUserId = userid 
    }else{ 
     loadingChatUserId = nil 
    } 
    } 
}else{ 
    loadingChatUserId = nil 
} 

はここで... UIApplicationLaunchOptionsRemoteNotificationKeyとして起動オプションをアンラップできている力、あなたの問題です。代わりにオプションのバインドを使用してください。

if let launchOpts = launchOptions { 
    if let remoteNotification = launchOpts[UIApplicationLaunchOptionsRemoteNotificationKey] as? NSDictionary{ 
     .... 
    } 
+0

もし私があなたに200ポイントを与えることができたら、私はそうするでしょう!どうもありがとう。これは私の日を救った。 – lnjuanj

関連する問題