Platformsios 7.0, requires ARC
FrameworksUIKit, Foundation



Samba is a mini port for Swift 2.0 availability checking. If you’ve been into the iOS development I’m sure that you know the tedious work to check if a particular API is available on the device your application is running on. Before Swift 2 availability check you probably had something like this

    // use registerUserNotificationSettings
    // use registerForRemoteNotificationTypes


if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
    // use registerUserNotificationSettings
} else {
    // use registerForRemoteNotificationTypes

or some macros for checking if the OS is at least a version and then do the dirty work. Well with Swift 2.0 this is as easy as

if #available(iOS 8.0, *) {
    // use registerUserNotificationSettings
} else {
    // use registerForRemoteNotificationTypes

Simple and elegant, that’s what we want. In Objective-C we don’t have that nice feature so Samba is trying to fix that hole with a simple function that do the system version check for you.

SKOperatingSystemVersion version = (SKOperatingSystemVersion) {8, 0, 0};

available(version, ^{
    // use registerUserNotificationSettings
}, ^{
    // use registerForRemoteNotificationTypes

Simple ha?, in the end Samba uses a simple compare againts [UIDevice currentDevice].systemVersion but it’s simpler than having all your code full of if’s checks.

Swift 2.0 availability check is more powerfull than this but you get the idea behind Samba, if you want to keep reading about this Swift new feature you can check this docs:


iOS 7.0 and later


Samba is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "Samba"


Oscar Antonio Duran Grillo, [email protected]


Samba is available under the MIT license. See the LICENSE file for more info.

Happy coding 🍻

Latest podspec

    "name": "Samba",
    "version": "0.1.0",
    "summary": "Swift availability check port for Objective-C",
    "description": "Samba is a mini port for Swift 2.0 availability checking.",
    "homepage": "",
    "license": "MIT",
    "authors": {
        "Oscar Antonio Duran Grillo": "[email protected]"
    "source": {
        "git": "",
        "tag": "0.1.0"
    "social_media_url": "",
    "platforms": {
        "ios": "7.0"
    "requires_arc": true,
    "source_files": "Pod/Classes/**/*",
    "frameworks": [

Pin It on Pinterest

Share This