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: 
In `Constants.swift`:

**Swift 1:**

```
let Device = UIDevice.currentDevice()
private let iosVersion = NSString(string: Device.systemVersion).doubleValue

```

**Swift 2:**

```
let Device = UIDevice.currentDevice()
private let iosVersion = Double(Device.systemVersion) ?? 0 

let iOS8 = iosVersion >= 8
let iOS7 = iosVersion >= 7 && iosVersion < 8

```

Then in other files

```
if iOS8
{

}
else
{

}

```
According to Apple, there are no preprocessor calls in Swift, but Swift code can be conditionally compiled based on the evaluation of build configurations in two functions. For now, we get 
`os()` for a choice of OSX or iOS and `arch()` for a choice of x86\_64, arm, arm64 or i386. So, you can evaluate `#if os(iOS)`, but not `#if os(iOS8)` (though that does seem like a good idea for the further versions of Swift).