检测并防止旧版 iOS 上的崩溃(怀疑 EventKit)
亲爱的学者们。 我使用最新的 SDK (4.2.1) 创建了一个简单的应用程序,该应用程序在所有 iOS 4.xx 设备上运行平稳且无错误。
最近,我收到一些使用较旧 iOS 版本的用户的评论,抱怨该应用程序在启动时崩溃,在苹果的崩溃日志中我什么也没看到。 继续我的调查,目前我唯一的怀疑是使用了 EventKit 类,如果没记错的话,它是在 iOS4 之后才引入的。
我在我的一门课程中很少使用它,它在 iOS4.2.1 上完美运行
#import <EventKit/EventKit.h>
//稍后
[self setADateInCal: [MyTimeArray objectAtIndex:0] :formatterDate];
因此我的问题:
这是否是导致我的应用程序在 iOS 上崩溃的问题< 4 ?
如何在不删除 iOS4 用户的功能的情况下防止它
一般来说,我如何测试这个?我的设备和 SDK 上有最新的官方 iOS,模拟器仅限于重新升级到 iOS 版本时可以返回多长时间...有什么神奇的方法可以做到这一点吗?
Dear Scholars.
I have created a simple application using the latest SDK (4.2.1), Which runs smoothly and error free on all devices with iOS 4.x.x.
Lately I am getting some comments from users with older iOS version complaining the application is crashing on start, on Apple's crash log I see nothing at all.
Pushing my investigation forward, the only suspect I have at the moment is the use of EventKit class, which if memory serves, where introduced only after iOS4.
I am using it very lightly in one of my classes, and it works perfectly on iOS4.2.1
#import <EventKit/EventKit.h>
//some time later
[self setADateInCal: [MyTimeArray objectAtIndex:0] :formatterDate];
Thus my Questions:
Can this be the issue that crashes my application on iOS < 4 ?
How can I prevent it without dropping the feature for people with iOS4
In general, How can I test this? I have the latest official iOS on my device and SDK, the simulator is limited to how back it can go in regrading to iOS version... any magical way to do so?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
1.) 是的。如果它不在 <4.0 中的 API 中,那么任何未运行 >4.0 的人都会崩溃。
2.) 使用 NSClassFromString(例如 Google)测试该类是否可用,并相应地 respondsToSelector 来查看您想要的方法是否可以在客户端运行的操作系统版本中使用。您可能还需要弱链接 EventKit 框架(再次 Google 了解如何执行此操作)。
3.) 测试这一点的唯一真正方法是将设备保留在您要测试的操作系统上。就我个人而言,我有一台旧 iPhone,我从来没有更新过运行 3.1.3 的东西,就像这样。或者,您可以将 xcode+iOSSDK 的旧安装保留在不同的分区或其他东西上,并使用它们的模拟器。 (我想对于未来的更新,因为你显然没有为 <4.0 做过这个)。但不,没有什么神奇的方法可以做到这一点。对不起。
为了清楚起见,请编辑第二点:基本上,您将检查您想要的类/方法是否在您当前运行的操作系统版本上可用,如果是,您可以使用它,如果不是,您将不得不找到解决方法(完全省略或以与旧版本兼容的其他方式进行)。
1.) Yes. If it wasn't in the API in <4.0 than anyone not running >4.0 will crash.
2.) Test to see if the class is available using NSClassFromString (Google for examples) and respondsToSelector in correspondence to see if the method you want is available to use in the OS version the client is running. You will also probably need to weak link the EventKit framework (again Google for how to do this).
3.) The only real way to test this is to keep a device at the OS you want to test. Personally, I have an old iPhone that I never update running 3.1.3 for things just like this. Alternatively, you can keep old installs of xcode+iOSSDK on different partitions or something and use their simulator. (for future updates i guess since you obviously haven't done this for <4.0). But no, there is no magical way to do this. sorry.
edit for clarity on Number 2: Basically you will check to see if the class/method you want is available on the OS version you are currently running, if it is you can use it, if not you will have to find a work around (omit completely or do it another way that is compliant with older versions).
是的,这可能会导致崩溃。缺少库的问题不会在苹果崩溃日志中报告任何内容。
为了防止这种情况发生,你需要做两件事,
弱链接 xcode 中的事件工具包库。
检查它在您的代码中是否存在,例如
,
在实际iOS版本上进行测试的唯一方法是获取运行ios的物理设备< 4.
Yes it could be causing the crash. Issues with missing libraries do not report anything in the apple crash log.
To prevent it from happening you need to do two things,
Weak link the event kit library in xcode.
Check for its existence in your code with something like
,
The only way to test on the actual iOS version is to get hold of a physical device running ios < 4.