i got an test app I'm writing with Swift, I want to target iOS 7. But enable local notification I need to add
application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: UIUserNotificationType.Sound
| UIUserNotificationType.Alert
| UIUserNotificationType.Badge,
categories: nil))
But this call is not available in iOS 7, so I added
var version:NSString = UIDevice.currentDevice().systemVersion as NSString;
if version.doubleValue >= 8 {
// ios 8 code
}
The ios 8 code block is only run in under iOS 8 (Tested), but when run the app in iOS 7 I still get
dyld: Symbol not found: _OBJC_CLASS_$_UIUserNotificationSettings Referenced from: /var/mobile/Applications/AC73969D-1A4C-45AC-99CA-0B3982C1EE36/Timely.app/Timely Expected in: /System/Library/Frameworks/UIKit.framework/UIKit in /var/mobile/Applications/AC73969D-1A4C-45AC-99CA-0B3982C1EE36/Timely.app/Timely
I assume it's because the binary contains symbol to api that doesn't exist in iOS 7, but how do i resolve this?
Unfortunately, I think you are running into a current limitation, see this
What is the Swift preprocessor equivalent to iOS version check comparison?
The only way to get around this is to add an Objective-C file, and then use #if
macros and make two helper functions that you call from Swift (one for iOS8 and one for iOS7). I expect this will be fixed at some point.
In Beta6 it appears that some (all?) of the linking problems have been fixed. Apps linked with UIAlertAction and UIAlertController used to fail to launch on 7.1, but now will launch. You still cannot use them in 7.1, but you can test for iOS version and use the older objects.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With