GKNotificationBanner在iOS 4.3.3上

我在iOS 4.1+应用程序中使用框架GKAchievementNotification(https://github.com/typeoneerror/GKAchievementNotification)。 这个应用程序是由苹果批准(在应用程序商店),但似乎在iOS 4.3.3崩溃。 崩溃日志如下:

OS Version: iPhone OS 4.3.3 (8J3) Report Version: 104 Exception Type: EXC_BREAKPOINT (SIGTRAP) Exception Codes: 0x00000001, 0xe7ffdefe Crashed Thread: 0 Dyld Error Message: Symbol not found: _OBJC_CLASS_$_GKNotificationBanner Referenced from: /var/mobile/Applications/08289A0B-7AD3-4E37-B29F-A EDFE97B7ACA/PolarDefense.app/PolarDefense Expected in: /System/Library/Frameworks/GameKit.framework/GameKit in /var/mobile/Applications/08289A0B-7AD3-4E37-B29F-AEDFE97B7ACA/PolarDefense.app/PolarDefense Dyld Version: 191.3 

看起来像框架没有正确地丢弃iOS版本的GKNotificationBanner,它不支持(5.0之前的iOS)。

我假设错误在于下面的代码,你认为它错了什么?

 @implementation GKAchievementHandler(private) - (void)displayNotification:(GKAchievementNotification *)notification { #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 50000 if ([GKNotificationBanner class]) { [GKNotificationBanner showBannerWithTitle:notification.title message:notification.message completionHandler:^{ [self didHideAchievementNotification:notification]; } ]; } else #endif { [_topView addSubview:notification]; [notification animateIn]; } } @end 

GKNotificationBanner参考了更多的地方,但总是被#if __IPHONE_OS_VERSION_MAX_ALLOWED> = 50000

那么它怎么会崩溃? (为什么只在发布模式?)

部署目标是4.1。 我现在读到,如果一个类存在的运行时检查只支持4.2。 这可能是问题吗?

#if语句将在编译时parsing,而不是在运行时parsing,而是检查基本SDK版本,而不是部署版本。 由于您正在构build最新的iOS版本,因此将始终执行此代码,而不pipe运行在哪个iOS版本上。

您可以在运行时检查可用性,如下所示:

 id GKNotificationBannerClass = NSClassFromString(@"GKNotificationBanner"); if (GKNotificationBannerClass) { .... 

认为这可能与我有一个必需的连接到GameKit有关。 将它改变为弱,并提交给App Store(第三次)。