I am getting
yld: Symbol not found: _OBJC_CLASS_$_UIUserNotificationSettings
and here's the function that is causing the error when the application is running on an iOS7 device and without even calling the function at all in the code.
func reigsterForRemoteUserNotifications(notificationTypes: UIUserNotificationType, categories: NSSet) { let userNotificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: categories) (UIApplication.sharedApplication()).registerUserNotificationSettings(userNotificationSettings) UIApplication.sharedApplication().registerForRemoteNotifications() }
I don't want this method to be accessible at all when running on an iOS7 device. I do not want a select check inside of it because that means the method is available for use to begin with.
What I want is a build config parameter to check the version : I can't figure out a way to write a swift equivalent preprocessor macro to check for the correct iOS version and neglect the new and undeclared iOS 8 library functions.
#if giOS8OrGreater
// declare the functions that are iOS 8 specific
#else
// declare the functions that are iOS 7 specific
#endif
In the documentation apple is suggesting functions and generics to substitute for complex macros but in this case I need a build config precompile check to avoid processing undeclared functions. Any suggestions.
NSProcessInfo().isOperatingSystemAtLeastVersion(yosemite)
seems to be checking whether OS X is Yosemite or not. Not sure if it would apply to iOS. – Lampleylet giOS8OrGreater...
with a compile time check#if giOS8OrGreater
This combination wouldn't have worked in Objective-C either. The preprocessor would look for a giOS8OrGreater preprocessor symbol, and not finding one, the #if will always fail. If you had the right side of the let statement as a #define, you'd just get a compile time error because the preprocessor has very limited expression evaluation capability. – Cutshall