How-tos

Deprecation of the Bluemix Mobile Services Objective-C SDKs

Share this post:

For the past year, we have been evolving our Objective-C SDKs alongside new Swift SDKs. Over the last few months, we have been investing more and more effort in the Swift SDKs, and we want to make sure that our developers are getting the best out of our mobile SDKs. To that effect, we’ve decided to deprecate the Bluemix Mobile Services Objective-C SDKs in favor of the Swift SDKs.

The deprecated components are:
IMFCore
IMFPush
IMFFacebookAuthentication
IMFGoogleAuthentication
IMFURLProtocol

Those components are replaced by new Swift SDKs:
BMSCore
BMSPush
BMSSecurity
BMSFacebookAuthentication
BMSGoogleAuthentication
BMSAnalytics

Objective-C SDKs will still be available for download for the next three months, but we strongly recommend that you move to the Swift SDKs to take advantage of all of the latest features and improvements. Don’t worry if you’re building your apps with Objective-C – you’ll still be able to use the Swift SDKs in your code. Just follow these instructions to move over to the Swift SDKs.

Migrating to the Swift SDKs

Step 1: Add BMSCore to dependencies

  1. Update your Podfile to include BMSCore as a dependency.
    Note: Uncomment use_frameworks! in your Podfile.
  2. Run pod update.

Step 2: Create a new BMSSDKBridge.swift file

  1. Accept the creation of the Objective-C bridging header when creating a new BMSSDKBridge.swift file. This is where you can import the BMSCore library and initialize it.
  2. See the following example code.
    import BMSCore
    @objc public class BMSClientObjc: NSObject {
    @objc public static let REGION_USSOUTH = BMSClient.Region.usSouth
    @objc public static let REGION_UK = BMSClient.Region.unitedKingdom
    @objc public static let REGION_SYDNEY = BMSClient.Region.sydney

    @objc public static func initialize(region: String) {
    let bmsClient = BMSClient.sharedInstance
    bmsClient.initialize(bluemixRegion: region)
    }
    }

    @objc public class RequestObjc: NSObject {
    private var request:Request?

    @objc public init(url: String, method: String, headers: [String: String]? = nil, queryParameters: [String: String]? = nil) {
    self.request = Request(url: url, method: HttpMethod.init(rawValue: method)!, headers: headers, queryParameters: queryParameters)
    }

    @objc public func send(completionHandler: @escaping (_ response: ResponseObjc? , _ error: Error?)->Void) {
    if let request = self.request {

    request.send(completionHandler: { (response, error) in
    if let response = response {
    completionHandler(ResponseObjc(response), error)
    } else {
    completionHandler(nil, error)
    }
    })
    }
    }
    }

    @objc public class ResponseObjc: NSObject {
    private var response: Response?

    public init(_ response: Response) {
    self.response = response;
    }

    @objc public func statusCode() -> Int {
    if let response = response, let statusCode = response.statusCode {
    return statusCode
    } else {
    return 0
    }
    }

    @objc public func headers () -> [AnyHashable: Any]? {
    return response?.headers
    }

    @objc public func responseText () -> String? {
    return response?.responseText
    }

    @objc public func responseData () -> Data? {
    return response?.responseData
    }

    @objc public func isSuccessful () -> Bool {
    if let response = response {
    return response.isSuccessful
    } else {
    return false
    }
    }
    }

Step 3: Initialize the BMSCore SDK in your AppDelegate.m file

  1. Import your bridging header at the top of your AppDelegate.m file:
    #import “Your_Project_Name-Swift.h”

    Note: Replace any project spaces with underscores.

  2. Initialize the BMSCore SDK. The new SDKs do not require an application ID or route. BMSCore requires only a region to initialize.
    (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [BMSClientObjc initializeWithRegion:[BMSClientObjc REGION_USSOUTH]];
    return YES;
    }

    Note: In the initializer, the bluemixRegion value specifies which Bluemix deployment you are using, for example, BMSClientObjc.REGION_US_SOUTH, BMSClientObjc.REGION_UK, or BMSClientObjc.REGION_SYDNEY.

Step 4: Comment out your existing IMFCore code and replace with equivalent BMSCore code

Following these basic steps should kickstart a successful migration to the Swift SDKs. If you run into any problems, you can open a question on StackOverflow.

More stories
May 1, 2019

Two Tutorials: Plan, Create, and Update Deployment Environments with Terraform

Multiple environments are pretty common in a project when building a solution. They support the different phases of the development cycle and the slight differences between the environments, like capacity, networking, credentials, and log verbosity. These two tutorials will show you how to manage the environments with Terraform.

Continue reading

April 29, 2019

Transforming Customer Experiences with AI Services (Part 1)

This is an experience from a recent customer engagement on transcribing customer conversations using IBM Watson AI services.

Continue reading

April 26, 2019

Analyze Logs and Monitor the Health of a Kubernetes Application with LogDNA and Sysdig

This post is an excerpt from a tutorial that shows how the IBM Log Analysis with LogDNA service can be used to configure and access logs of a Kubernetes application that is deployed on IBM Cloud.

Continue reading