Building iOS Apps with QuickBlox and Swift

Posted on by Nate Macleitch

As everybody already knows Apple released a new programming language called Swift. Swift is the result of the latest research on programming languages, combined with decades of experience building Apple platforms. It is an innovative new programming language for Cocoa and Cocoa Touch. Writing code is interactive and fun, the syntax is concise yet expressive, and apps run lightning-fast. To learn more about Swift, checkout Apple’s reference book.

Swift is ready for your next iOS  project — or for addition into your current app — because Swift code works side-by-side with Objective-C.
And QuickBlox is not an exception. Swift is fully compatible with existing Objective-C libraries, including system libraries like Foundation and third-party libraries like QuickBlox.

To start with QuickBlox and Swift we prepared a demo application which shows how to work with QuickBlox and Swift together.
To connect QuickBlox iOS SDK to your Swift application you need:

  1. Add a new file to your project, an Objective-C .m file.
  2. When prompted about creating a bridge header file, approve the request.
  3. Remove the unused .m file you added.
  4. Add your Objective-C import statements to the created bridge header .h file:
    @import UIKit;
    @import Foundation;
    @import SystemConfiguration;
    @import MobileCoreServices;
    #import <Quickblox/Quickblox.h>

After this you can start using the QuickBlox framework in your Swift project.

As an additional here is an example how to create an object for  CustomObjects module:

let object = QBCOCustomObject()
object.className = "Movie"
var params = ["title": "How to Train Your Dragon 2 ",
              "year": "2014"].bridgeToObjectiveC() as NSMutableDictionary      
object.fields = params
QBCustomObjects.createObject(object, delegate: self)


func completedWithResult(result: Result){
    if result is QBCOCustomObjectResult{
        if result.success{

That’s all you need to know to start. For any further questions please ask ‘quickblox’ tagged question on StackOverflow