Search code examples
iosswiftcocoaquickblox

Connecting Quickblox to app using cocoa pods


I have tried everything I can to get my swift app connected to Quickblox.

I'm using Cocoa pods witht he following podfile:

# Uncomment this line to define a global platform for your project
platform :ios, '9.2'
# Uncomment this line if you're using Swift
use_frameworks!

target 'chat-ios' do

pod 'QuickBlox'

post_install do |installer|
installer.pods_project.build_configuration_list.build_configurations.each do $
configuration.build_settings['CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK$
end
end

end

I've then added a bridging header which I borrowed from the Quickblox swift example but it fails to work.

I get a host of errors as shown in the Quickblox.h file:

error in xcode

I also get errors in the bridging file along the lines of:

Could not build module Quickblox.h QMServices.h file not found.


Solution

  • I'm new to Quickblox, but i made successful way through cocoa pods. Using this guide:

    started here, and just followed the movie.

    if after

    "sudo gem install cocoapods" 
    

    you get an error:

    ERROR:  While executing gem ... (Errno::EPERM)
    Operation not permitted - /usr/bin/xcodeproj 
    

    try

    sudo gem install -n /usr/local/bin cocoapods
    

    after setting up pods follow this swift-connection-guide

    and after don't forget to continue first link , at the bottom of it there are some notes about setting up your app with Quickblox security keys.

    note, that

    [QBApplication sharedApplication].applicationId = your_app_id;;
    [QBConnection registerServiceKey:@"your_app_service_key"];;
    [QBSettings setAuthorizationSecret:@"your_app_authorization_secret"];;
    //Go to admin.quickblox.com/account and copy Account Key: 
    [QBSettings setAccountKey:accountKey];
    

    is Obj-C and some methods are deprecated. Now use:

        QBSettings.setApplicationID(XXXXX)    // integer, no ""
        QBSettings.setAuthKey("XXXXXXXXX")    // Your
        QBSettings.setAuthSecret("XXXXXXXXX") // keys
        QBSettings.setAccountKey("XXXXXXXXX") // here
    

    In AppDelegate don't forget :

    import Quickblox
    

    if Xcode does not bark at you (that Quickblox is Obj-c) - probably you win.