Gagan_iOS February 2016

Quickblox APIs in swift crashes with unrecognized selector

I have an issue with Quickblox when I am trying to integrate code in Swift.

Below code ruuning in Objective-C without any error

AppDellgate.m file

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [QBSettings setApplicationID:kApplicationID];
    [QBSettings setAuthKey:kAuthKey];
    [QBSettings setAuthSecret:kAuthSecret];
    [QBSettings setAccountKey:kAcconuntKey];

    [[GeoDataManager instance] fetchLatestCheckIns];    

    return YES;
}

GeoDataManager.m file

@implementation GeoDataManager

+ (instancetype)instance
{
    static GeoDataManager *instance = nil;
    static dispatch_once_t onceToken;

    dispatch_once(&onceToken, ^{
        instance = [self new];
    });

    return instance;
}

- (void)fetchLatestCheckIns
{
    QBLGeoDataFilter* filter = [QBLGeoDataFilter new];
    filter.lastOnly = YES;
    filter.sortBy = GeoDataSortByKindCreatedAt;

    QBGeneralResponsePage *page = [QBGeneralResponsePage responsePageWithCurrentPage:1 perPage:70];

    [QBRequest geoDataWithFilter:filter                            page:page                    successBlock:^(QBResponse *response, NSArray *objects, QBGeneralResponsePage *page) {
                        [[DataManager sharedDataManager] saveCheckIns:objects];
                    } errorBlock:^(QBResponse *response) {

                        NSLog(@"Error = %@", response.error);

                    }];
}

But when I trying to call the same method from my Swift base project from below code

Swift AppDelegate.

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

        // Set QuickBlox credentials (You must create application in admin.quickblox.com).
        QBSettings.setApplicationID(kQBApplicationID)
        QBSettings.setAuthKey(kQBAuthKey)
        QBSettings.s        

Answers


SevenDays February 2016

Seems you don't have needed linker flags

  1. Full guide http://quickblox.com/developers/IOS-how-to-connect-Quickblox-framework
  2. Please take a look at the Step 7:

Add -lxml2, -ObjC, -lstdc++ flags to Other Linker Flags section in project settings

Post Status

Asked in February 2016
Viewed 2,806 times
Voted 11
Answered 1 times

Search




Leave an answer