Fra*_*ank 2 xcode ios ios5 ios6 xcode4.5
我有一个使用Xcode Version 4.5.1开发的iOS应用程序.我的iOS部署目标设置为5.0,因为我希望该应用程序能够在iOS 5.0,5.1和6.0上运行.
当我在iOS 6设备(或模拟器)上运行应用程序时,一切正常.当我在iOS 5设备(或模拟器)上运行应用程序时,应用程序在UIApplicationMain中崩溃.我可以通过应用程序:didFinishLaunchingWithOptions:并且它似乎正在成功执行.这是堆栈跟踪:

如果它有帮助,这是寄存器:
(lldb) register read
General Purpose Registers:
eax = 0x06e5f590
ebx = 0x01226f9c "class"
ecx = 0x0733fb8c
edx = 0x0733fb90
edi = 0x0011d814 (void *)0x0011d800: TRAppDelegate
esi = 0xbffff310
ebp = 0xbffff2e8
esp = 0xbffff2a0
eflags = 0x00000286
eip = 0x00002b3d Messenger`main + 141 at main.m:16
6 registers were unavailable.
(lldb)
Run Code Online (Sandbox Code Playgroud)
回溯:
(lldb) bt
* thread #1: tid = 0x1c03, 0x01211caa libobjc.A.dylib`objc_exception_throw, stop reason = breakpoint 1.3 2.3
frame #0: 0x01211caa libobjc.A.dylib`objc_exception_throw
frame #1: 0x015cda48 CoreFoundation`+[NSException raise:format:arguments:] + 136
frame #2: 0x015cd9b9 CoreFoundation`+[NSException raise:format:] + 57
frame #3: 0x006954a3 UIKit`UINibDecoderDecodeObjectForValue + 281
frame #4: 0x0069567b UIKit`UINibDecoderDecodeObjectForValue + 753
frame #5: 0x00695383 UIKit`-[UINibDecoder decodeObjectForKey:] + 117
frame #6: 0x0059516d UIKit`-[UINib instantiateWithOwner:options:] + 921
frame #7: 0x0043b1fc UIKit`-[UIViewController _loadViewFromNibNamed:bundle:] + 286
frame #8: 0x0043b779 UIKit`-[UIViewController loadView] + 302
frame #9: 0x0043b99b UIKit`-[UIViewController view] + 53
frame #10: 0x0039a401 UIKit`-[UIWindow addRootViewControllerViewIfPossible] + 45
frame #11: 0x0039a670 UIKit`-[UIWindow _setHidden:forced:] + 280
frame #12: 0x0039a836 UIKit`-[UIWindow _orderFrontWithoutMakingKey] + 49
frame #13: 0x003a172a UIKit`-[UIWindow makeKeyAndVisible] + 35
frame #14: 0x00372596 UIKit`-[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1820
frame #15: 0x00373274 UIKit`-[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 524
frame #16: 0x00382183 UIKit`-[UIApplication handleEvent:withNewEvent:] + 1027
frame #17: 0x00382c38 UIKit`-[UIApplication sendEvent:] + 68
frame #18: 0x00376634 UIKit`_UIApplicationHandleEvent + 8196
frame #19: 0x02314ef5 GraphicsServices`PurpleEventCallback + 1274
frame #20: 0x015f9195 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
frame #21: 0x0155dff2 CoreFoundation`__CFRunLoopDoSource1 + 146
frame #22: 0x0155c8da CoreFoundation`__CFRunLoopRun + 2218
frame #23: 0x0155bd84 CoreFoundation`CFRunLoopRunSpecific + 212
frame #24: 0x0155bc9b CoreFoundation`CFRunLoopRunInMode + 123
frame #25: 0x00372c65 UIKit`-[UIApplication _run] + 576
frame #26: 0x00374626 UIKit`UIApplicationMain + 1163
frame #27: 0x00002b3d Messenger`main + 141 at main.m:16
(lldb)
Run Code Online (Sandbox Code Playgroud)
问题
禁用自动布局
您可能正在使用iOS 6中提供的功能,例如AutoLayout.打开您的界面文件并确保取消选中AutoLayout:

可以在实用程序检查器(Xcode右侧的窗格)中找到此AutoLayout切换,然后在Utilities Inspector的第一个选项卡(File Inspector)下找到.您还可以将文档版本控制部署设置更改为您的应用支持的最低iOS版本.执行此操作后,Xcode将显示界面中已弃用或某些iOS版本可能不支持的功能的警告.
是的,当然您可以使用Xcode 4.5为早期版本的iOS开发应用程序.只需确保在项目设置中正确设置了部署目标.
DrummerB对3和4的建议应该运作良好:
我不认为这会有所帮助.也许您可以尝试在应用程序崩溃时在调试控制台中运行bt以获取跟踪.
另外,为了改进DrummerB的答案,可以使用iOS 6类/ API,但在使用之前必须检查它们的可用性:
if ([UIClassName class] != nil) {
//UIClassName is available, you can now set it up
} else {
//UIClassName is not available, use a different class or prompt the user
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3698 次 |
| 最近记录: |