+ Start a Discussion
Jyoti Singh 9Jyoti Singh 9 

Can I use Mobile SDK with Swift?

Does anyone have sample code which uses iOS MObile SDK in a Swift project?
Best Answer chosen by Jyoti Singh 9
Gaurav KheterpalGaurav Kheterpal
You can refer to this (https://developer.salesforce.com/blogs/developer-relations/2014/06/integrating-swift-into-an-existing-salesforce-ios-project.html) detailed tutorial with videos about how you can integrate Swift code into your iOS Mobile project. The source code is open source and available here (https://github.com/rajaraodv/Swifty).

The key thing is that you need to create a bridging class for integrating Swift and Obj-C code together.
 
#import <UIKit/UIKit.h>
#import "SFRestAPI.h"
#import "SFRestRequest.h"
This then makes your SF Rest API classes available for consumption in Swift files.

If my answer helps resolve your query, please mark it as the 'Best Answer' to benefit others and improve the overall quality of Discussion Forums.

All Answers

Gaurav KheterpalGaurav Kheterpal
You can refer to this (https://developer.salesforce.com/blogs/developer-relations/2014/06/integrating-swift-into-an-existing-salesforce-ios-project.html) detailed tutorial with videos about how you can integrate Swift code into your iOS Mobile project. The source code is open source and available here (https://github.com/rajaraodv/Swifty).

The key thing is that you need to create a bridging class for integrating Swift and Obj-C code together.
 
#import <UIKit/UIKit.h>
#import "SFRestAPI.h"
#import "SFRestRequest.h"
This then makes your SF Rest API classes available for consumption in Swift files.

If my answer helps resolve your query, please mark it as the 'Best Answer' to benefit others and improve the overall quality of Discussion Forums.
This was selected as the best answer
Jyoti Singh 9Jyoti Singh 9
Thanks, this is helpful. Can you also tell me if there is a pure Swift implementation using Mobile SDk without using bridging?
BlueCloudBlueCloud
This post has details and sameple code to build a narive iOS Salesforce app in Swift.  http://4loopers.io/developing-ios-apps-using-swift/
 
mike4adaymike4aday
See Swiftly Salesforce, an all-Swift, open-source framework for building native iOS apps on Salesforce:
https://github.com/mike4aday/SwiftlySalesforce