我在iPad Air上运行一个用Swift编写的iOS应用程序,带有一个临时分发配置文件。在这个版本中,我的应用程序被iOS启动计时器崩溃,说它没有及时启动。我找到了解释,说我应该从app委托的didFinishLaunchingWithOptions中删除繁重的操作。奇怪的是,那里几乎没有任何东西。
func application(application: UITimedApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Register default settings
let appDefaults = [
"jsonURL": "http://192.168.178.156:8888/people.json",
"apiBaseURL": "http://192.168.178.156:8888",
"idleTimeout": 3,
"numberOfPeople": 2147
]
NSUserDefaults.standardUserDefaults().registerDefaults(appDefaults)
// Listen to charge state changes
UIDevice.currentDevice().batteryMonitoringEnabled = true
NSNotificationCenter.defaultCenter().addObserver(self, selector: "updateDeviceTimer", name: UIDeviceBatteryStateDidChangeNotification, object: nil)
updateDeviceTimer()
return true
}
此处调用的唯一其他函数是:
func updateDeviceTimer() {
switch UIDevice.currentDevice().batteryState {
case .Unknown, .Unplugged:
UIApplication.sharedApplication().idleTimerDisabled = false
default:
UIApplication.sharedApplication().idleTimerDisabled = true
}
}
另一方面是我使用Apple Configurator将iPad锁定为仅使用此应用程序。结果是,在启动计时器发生五次崩溃后,"指导访问应用程序无法使用,请联系您的管理员"消息显示,表示不允许更多交互。在此警报消息下方,您可以看到应用最终完成了启动。
加载的第一个视图控制器也非常轻量级,显示一些标签和一个开始按钮。该应用程序使用Core Data,但不是在加载了开始按钮的第二个视图控制器之前。
我无法理解为什么该应用需要很长时间才能启动。 iOS监视程序计时器只是查看didFinishLaunchingWithOptions方法的返回值,还是你在事后做的事情呢?
我尝试使用计时器来分析应用程序,但我真的不知道如何阅读。另外,在调试模式下,我根本没有这个问题,因此仪器用处不大。
有关如何调试此问题的任何想法?
这是描述崩溃的崩溃报告:
Incident Identifier: 5069F06D-B9A1-427C-B093-5118D926A3E7
CrashReporter Key: fec3be8efd13f8877e4a696ef5cf14eba092b2cd
Hardware Model: iPad4,1
Process: NamesNotNumbers [146]
Path: /private/var/mobile/Containers/Bundle/Application/28D4887C-9C3D-4E3B-9F88-C3F18E6AF409/<APP BUNDLE>/NamesNotNumbers
Identifier: <My App bundle>
Version: 1 (1.0)
Code Type: ARM-64 (Native)
Parent Process: launchd [1]
Date/Time: 2015-03-23 11:13:57.770 +0100
Launch Time: 2015-03-23 11:13:35.939 +0100
OS Version: iOS 8.1.3 (12B466)
Report Version: 105
Exception Type: 00000020
Exception Codes: 0x000000008badf00d
Highlighted Thread: 0
Application Specific Information:
<APP BUNDLE> failed to launch in time
Elapsed total CPU time (seconds): 6.260 (user 6.260, system 0.000), 14% CPU
Elapsed application CPU time (seconds): 0.003, 0% CPU
Thread 0:
0 dyld 0x00000001200adaa8 __fcntl + 8
1 dyld 0x00000001200ad4b4 fcntl + 120
2 dyld 0x000000012009b9cc ImageLoaderMachO::loadCodeSignature(linkedit_data_command const*, int, unsigned long long, ImageLoader::LinkContext const&) + 64
3 dyld 0x000000012009e3c0 ImageLoaderMachOCompressed::instantiateFromFile(char const*, int, unsigned char const*, unsigned long long, unsigned long long, stat const&, unsigned int, unsigned int, linkedit_data_command const*, encryption_info_command const*, ImageLoader::LinkContext const&) + 228
4 dyld 0x000000012009a9bc ImageLoaderMachO::instantiateFromFile(char const*, int, unsigned char const*, unsigned long long, unsigned long long, stat const&, ImageLoader::LinkContext const&) + 244
5 dyld 0x000000012008f900 dyld::loadPhase6(int, stat const&, char const*, dyld::LoadContext const&) + 408
6 dyld 0x00000001200940c8 dyld::loadPhase5stat(char const*, dyld::LoadContext const&, stat*, int*, bool*, std::__1::vector<char const*, std::__1::allocator<char const*> >*) + 168
7 dyld 0x0000000120093f88 dyld::loadPhase5(char const*, char const*, dyld::LoadContext const&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) + 640
8 dyld 0x0000000120093cd0 dyld::loadPhase4(char const*, char const*, dyld::LoadContext const&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) + 188
9 dyld 0x0000000120093940 dyld::loadPhase3(char const*, char const*, dyld::LoadContext const&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) + 648
10 dyld 0x0000000120093468 dyld::loadPhase1(char const*, char const*, dyld::LoadContext const&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) + 156
11 dyld 0x000000012008f444 dyld::loadPhase0(char const*, char const*, dyld::LoadContext const&, std::__1::vector<char const*, std::__1::allocator<char const*> >*) + 232
12 dyld 0x000000012008f0f8 dyld::load(char const*, dyld::LoadContext const&) + 156
13 dyld 0x0000000120092ea4 dyld::libraryLocator(char const*, bool, char const*, ImageLoader::RPathChain const*) + 48
14 dyld 0x000000012009866c ImageLoader::recursiveLoadLibraries(ImageLoader::LinkContext const&, bool, ImageLoader::RPathChain const&) + 336
15 dyld 0x0000000120098354 ImageLoader::link(ImageLoader::LinkContext const&, bool, bool, bool, ImageLoader::RPathChain const&) + 104
16 dyld 0x00000001200908e0 dyld::link(ImageLoader*, bool, bool, ImageLoader::RPathChain const&) + 180
17 dyld 0x0000000120091718 dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) + 2244
18 dyld 0x000000012008d040 _dyld_start + 64
No thread state (register information) available
Binary Images:
0x100050000 - 0x1000e3fff NamesNotNumbers arm64 <aac22e8e51b7365aa86fb7688118c1af> /var/mobile/Containers/Bundle/Application/28D4887C-9C3D-4E3B-9F88-C3F18E6AF409/NamesNotNumbers.app/NamesNotNumbers
0x10012c000 - 0x1002b7fff libswiftCore.dylib arm64 <5b3c2ad007c73590aabdc2554ff30d4a> /var/mobile/Containers/Bundle/Application/28D4887C-9C3D-4E3B-9F88-C3F18E6AF409/NamesNotNumbers.app/Frameworks/libswiftCore.dylib
0x100414000 - 0x10042bfff libswiftCoreGraphics.dylib arm64 <4df212c0adc635d39677885bf1eb5500> /var/mobile/Containers/Bundle/Application/28D4887C-9C3D-4E3B-9F88-C3F18E6AF409/NamesNotNumbers.app/Frameworks/libswiftCoreGraphics.dylib
0x10045c000 - 0x10045ffff libswiftCoreImage.dylib arm64 <652ee890902b3ea68b86a72cd280faa5> /var/mobile/Containers/Bundle/Application/28D4887C-9C3D-4E3B-9F88-C3F18E6AF409/NamesNotNumbers.app/Frameworks/libswiftCoreImage.dylib
0x10046c000 - 0x100473fff libswiftDarwin.dylib arm64 <6883570852443a6db73321866cb0c1c2> /var/mobile/Containers/Bundle/Application/28D4887C-9C3D-4E3B-9F88-C3F18E6AF409/NamesNotNumbers.app/Frameworks/libswiftDarwin.dylib
0x10048c000 - 0x10048ffff libswiftDispatch.dylib arm64 <cd8f8e2d57113862afda4788f098adaa> /var/mobile/Containers/Bundle/Application/28D4887C-9C3D-4E3B-9F88-C3F18E6AF409/NamesNotNumbers.app/Frameworks/libswiftDispatch.dylib
0x1004b8000 - 0x100503fff libswiftFoundation.dylib arm64 <44c6c5841e3b3c9486958cbf1a534bd4> /var/mobile/Containers/Bundle/Application/28D4887C-9C3D-4E3B-9F88-C3F18E6AF409/NamesNotNumbers.app/Frameworks/libswiftFoundation.dylib
0x100554000 - 0x10055bfff libswiftObjectiveC.dylib arm64 <252990df94bf3dc899190b1d8df925df> /var/mobile/Containers/Bundle/Application/28D4887C-9C3D-4E3B-9F88-C3F18E6AF409/NamesNotNumbers.app/Frameworks/libswiftObjectiveC.dylib
0x100578000 - 0x10057bfff libswiftSecurity.dylib arm64 <c6fd1c806cfe38cba2b21c780642b0fb> /var/mobile/Containers/Bundle/Application/28D4887C-9C3D-4E3B-9F88-C3F18E6AF409/NamesNotNumbers.app/Frameworks/libswiftSecurity.dylib
0x12008c000 - 0x1200b3fff dyld arm64 <21c893f791653e989e1c3e15446d772b> /usr/lib/dyld
0x183cfc000 - 0x183f07fff CFNetwork arm64 <68adcebf440d30769bd2d67adc7932a2> /System/Library/Frameworks/CFNetwork.framework/CFNetwork
0x18404c000 - 0x18428afff CoreData arm64 <33c0d795a45e35c9affed5cf9d83a8a1> /System/Library/Frameworks/CoreData.framework/CoreData
0x18428c000 - 0x1845e8fff CoreFoundation arm64 <83a9627362333366a8543e8c2d28166e> /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
0x1845ec000 - 0x18474efff CoreGraphics arm64 <7a02a2d0b69f3706b3cb91726db6f8af> /System/Library/Frameworks/CoreGraphics.framework/CoreGraphics
0x185190000 - 0x1853e4fff Foundation arm64 <e596bd80bcc83f15aca36a7ef014f457> /System/Library/Frameworks/Foundation.framework/Foundation
0x1884a8000 - 0x18862cfff QuartzCore arm64 <313aba56d17e30d1b68b2fdfda1820f8> /System/Library/Frameworks/QuartzCore.framework/QuartzCore
0x188b50000 - 0x1894c5fff UIKit arm64 <a1283daa6f5a33048ab9d29d91f62c09> /System/Library/Frameworks/UIKit.framework/UIKit
0x1942bc000 - 0x1942bdfff libSystem.B.dylib arm64 <882b19bba06d348d97fcdaf545163f47> /usr/lib/libSystem.B.dylib
0x194db8000 - 0x194fb4fff libobjc.A.dylib arm64 <e6224d745a023588af8e5bb67498139a> /usr/lib/libobjc.A.dylib