iOS8・Xcode7.3、swift2という環境でiOSアプリの開発を行っています。
現在、あるURLをsafariで起動するという実装を行っており、UIApplication.sharedApplication().openURL(url!)
を利用することで無事起動することが出来ました。
swift
1 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) { 2 if url != nil && UIApplication.sharedApplication().canOpenURL(url!) { 3 UIApplication.sharedApplication().openURL(url!) 4 } 5}
しかし、Safariを開いたあとにアプリに戻ってくると例外なく、AppDelegate.swift
でクラッシュします。エラーログは一切出ません。
対処策として、Safariを開いた直後に、ViewControllerを変更する(self.navigationController?.popViewControllerAnimated(true)
のようなメソッドを呼び出す)とクラッシュは防げます。
何卒宜しくお願い致します。
追記
TakeOneさんからの質問
sharedApplication().openURL(url!)
の行だけ削除したらSafariが起動されないだけでクラッシュしなくなるんですか
こちらはクラッシュ致しませんでした。
openURLの実行によりアプリはバックグラウンド状態に移行しますから、その際にapplicationWillResignActive()やapplicationDidEnterBackground()が呼ばれます。
また、戻ってくる際にはapplicationWillEnterForeground()やapplicationDidBecomeActive()が呼ばれます。
そのあたりに問題のある処理がないか確認した方がよいと思います。
こちらも現在行っていた処理をすべてなくしても同じ現象でした。
ちなみにapplicationWillEnterForeground()が呼ばれる前にクラッシュしております。
また、[Window]-[Devices]でデハッグ中の端末を選択すると、端末のコンソールメッセージが表示されますから、それを確認すれば、何か見えてなかったものが見えてくるかもしれません。
コンソールで確認し、ログを取得出来たので追記させていただきました。
####デバイスログ
Safariへの遷移時
Sep 4 09:31:19 assertiond[30736]: assertion failed: 15E65 13E230: assertiond + 15801 [3C808658-78EC-3950-A264-79A64E0E463B]: 0x1 Sep 4 09:31:19 --- last message repeated 5 times --- Sep 4 09:31:19 assertiond[30736]: assertion failed: 15E65 13E230: assertiond + 17314 [3C808658-78EC-3950-A264-79A64E0E463B]: 0x1 Sep 4 09:31:19 assertiond[30736]: assertion failed: 15E65 13E230: assertiond + 53689 [3C808658-78EC-3950-A264-79A64E0E463B]: 0x1 Sep 4 09:31:20 assertiond[30736]: assertion failed: 15E65 13E230: assertiond + 15801 [3C808658-78EC-3950-A264-79A64E0E463B]: 0x1 Sep 4 09:31:20 --- last message repeated 2 times --- Sep 4 09:31:20 SpringBoard[30732]: [MPUSystemMediaControls] Updating supported commands for now playing application. Sep 4 09:31:20 assertiond[30736]: assertion failed: 15E65 13E230: assertiond + 15801 [3C808658-78EC-3950-A264-79A64E0E463B]: 0x1
アプリへ戻ってくる時
Sep 4 09:33:19 assertiond[30736]: assertion failed: 15E65 13E230: assertiond + 15801 [3C808658-78EC-3950-A264-79A64E0E463B]: 0x1 Sep 4 09:33:19 syslogd[30718]: ASL Sender Statistics Sep 4 09:33:19 assertiond[30736]: assertion failed: 15E65 13E230: assertiond + 15801 [3C808658-78EC-3950-A264-79A64E0E463B]: 0x1 Sep 4 09:33:19 --- last message repeated 3 times --- Sep 4 09:33:19 assertiond[30736]: assertion failed: 15E65 13E230: assertiond + 53689 [3C808658-78EC-3950-A264-79A64E0E463B]: 0x1 Sep 4 09:33:19 SpringBoard[30732]: [MPUSystemMediaControls] Updating supported commands for now playing application. Sep 4 09:33:19 assertiond[30736]: assertion failed: 15E65 13E230: assertiond + 15801 [3C808658-78EC-3950-A264-79A64E0E463B]: 0x1
※時々CoreAnimation: updates deferred for too long
というメッセージが表示されています。

バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/09/04 00:33