Question: 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.

Answer: 
**Update:** This is fixed in Xcode 6 beta 6 (build 6A280e)

---

~~Here's a (perhaps not so great) workaround: explicitly link to UIKit weakly (I know that `import` statements are supposed to link to frameworks already, but we do it explicitly anyway).~~

* Click on the project in Xcode
* select the target in the drop down at the top left
* go to General tab
* scroll down to Linked Frameworks and Libraries
* add UIKit.framework
* change Status from Required to Optional

It may cause all of UIKit to be weakly linked, which may affect performance. Not sure.

In Objective-C, even with Required, the compiler automatically weak-linked the symbols whose availability is above the deployment target, and leave the others strongly linked. I don't know why this doesn't work with Swift.
You can check iOS version by -

```
let iosVersion = UIDevice.currentDevice().systemVersion

```

And compare it using NSStringCompareOptions.NumericSearch

```
switch iosVersion.compare("8.0.0", options: NSStringCompareOptions.NumericSearch)
{
    case .OrderedSame, .OrderedDescending:
        //iOS>=8.0.0
        return LAContext()
    case .OrderedAscending:
        //iOS<8.0.0
        return nil
}

```

You can also use the new NSProcessInfo APIs, but they're unavailable for iOS 7.

```
if NSProcessInfo().isOperatingSystemAtLeastVersion(NSOperatingSystemVersion(majorVersion: 8, minorVersion: 0, patchVersion: 0)) {
//iOS>=8.0.0
}

```

You can see more details [here](http://nshipster.com/swift-system-version-checking/). Hope this solves your query.