App 不能啟動錯誤:“failed to launch in time”

來源:互聯網
上載者:User

標籤:

App不能啟動。裝置日誌輸出:

MyApp failed to launch in time

Elapsed total CPU time (seconds): 13.700 (user 8.580, system 5.120), 67% CPU  Elapsed application CPU time(seconds): 6.180, 30% CPU

 

同時:

1、該App在模擬器中不會出現此問題。

2、在Debug模式(串連裝置)也不會出現此問題,App能正常啟動。

3、App 商店不會拒絕App的提交。當然,很可能蘋果測試人員使用的裝置要比你的快。

4、如果使用者使用一些老裝置,如3GS,則會出現此問題。

……

 

凡此種種,都表明,你在didFinishLaunchingWithOptions方法中加入了太多的代碼。

這是因為,如果App主線程的啟動時間過長,iOS會強制終止App運行。

 

解決的辦法很簡單,將didFinishLaunchingWithOptions方法中比較“費時”的代碼(比如openURL其實是一個很費時的操作)放到後台線程中進行:

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0),  { () -> Void in

if true== UIApplication.sharedApplication().canOpenURL(NSURL(string: "xxx://")!){

    UIApplication.sharedApplication().openURL(NSURL(string:"xxx://")!)

}

})

 

App 不能啟動錯誤:“failed to launch in time”

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.