Empowering Everyone to Build World-Class iOS Apps with Salesforce

This was originally published on link to post

Today everything is connected and everything is mobile. People expect access to their data and their apps across all their devices, and this means that as developers we have more work to do than ever. To make it easier to build amazing, enterprise-class mobile apps, Apple and Salesforce have announced a strategic partnership to redefine the mobile customer experience and to empower learning for all.

For developers, this partnership gives you access to the tools and educational resources you’ll need to start building custom apps for iOS that leverage customer data from Salesforce. These resources include an all-new Salesforce Mobile SDK for iOS optimized for Swift, and new learning content on Trailhead built in collaboration with Apple.

Let’s start by taking a look at how Swift makes it easy to build great apps on iOS.

Introduction to Swift

Swift is a modern programming language that is perfect for developing mobile apps, and is designed to be safe, fast, and expressive. Some of the features that make Swift a modern language include:

  • Clean, easy to read, declarative syntax
  • Powerful error handling and throwing capabilities
  • Built-in type safety and inference
  • Handles values that might not exist with new Optional type
  • Simple functional computations with map, filter, reduce
  • Developed in the open, with community input and support – and much more!

Let’s take a look at how simple it is to read a Swift code sample:

As you can see, the syntax is simple and is to understand – even at first glance! Next, let’s take a look at a slightly more complicated code sample where we define a Type called person that contains two variables for First Name and Last Name. And then we’ll also define two instances of the person using constants.

When coding in Swift you get a unique feature called Optional to define variables that may or may not contain a value, as well as modern capabilities like Switch statements to efficiently handle things like flow control. Let’s take a look at how this works:

The first thing you might have noticed when you look at this code sample is that you can use emojis when defining constants, variables and values! While that’s a fun and useful way to code in the modern era, what’s even more exciting is the power you get from the Optional type and switch statement features. At the start of the code sample, we defined a variable called animal as an optional string indicated by “String?” and set its value to 😺. We then evaluated the Optional to see if it had a value and used the switch statement (via case) to further evaluate our value. Here’s how it looks in the Xcode IDE and you can see the expected value printed out in the console at the bottom of the screenshot below:

Now that you’ve had a quick introduction to Swift, let’s take a look at how you can start building iOS apps that connect to Salesforce data.

Building iOS apps with Swift and the Salesforce Mobile SDK

The Salesforce Mobile SDK incorporates all the benefits of Swift, Apple’s flagship programming language, and allows you to build custom mobile applications on Salesforce with great services such as:

  • Offline synchronization of Salesforce data with SmartSync
  • Encrypted storage with SmartStore

Let’s take a quick look at how easy it is to synchronize data between your iOS app and Salesforce with this Swift code sample:

Taking a look at this code, you can immediately see that it is both simple and powerful. Let’s review:

  1. Target: specify which records you want to sync.
  2. Options: define sync logic. For example, you can set the sync to overwrite modified records or leave them alone.
  3. Soup: This value might look delicious, but it’s a self-contained data set (or table) in the underlying SQLite database that comes with the Salesforce Mobile SDK. It typically maps to a standard or custom object.
  4. SyncName: create, delete, run or re-run a named sync operation at runtime

In addition to powerful Mobile SDK features like secure storage and out-of-the-box synchronization, you access to a ton of trusted enterprise services from the Salesforce platform, without having to reinvent the wheel, such as:

  • Access control, authentication, user management, and mobile device management
  • Social collaboration and file storage with Chatter
  • Salesforce Mobile Push Notification Services
  • Massively scalable mobile backends on Heroku

As part of this partnership, Salesforce and Apple are working together to optimize Swift support in the Salesforce Mobile SDK. The new SDK will make it easier for developers to use native iOS features and constants and enums are now namespaced for better discoverability. A developer preview of the new SDK will be coming soon!

Start learning with Trailhead and join us at Dreamforce

Together, Salesforce and Apple are launching new learning content on Trailhead to help everyone learn how to build native iOS apps with Swift and Xcode. Effective today, you can take the new Get Started with iOS App Development trail and earn the following badges:

  • Swift Essentials – new!
  • Xcode Essentials – new!
  • Salesforce Mobile SDK Basics
  • Native iOS

By taking this trail, you will get a hands-on introduction to Swift, create a basic iOS app with Xcode, and learn how to leverage data and services from Salesforce in a secure, trusted environment. Updates to the Salesforce Mobile SDK Basics and Native iOS modules are coming this fall, and all of this content is available free on Trailhead today.

And if you’re joining us at Dreamforce, make sure to stop by the Apple and Salesforce area in the Trailhead Zone (Moscone West, 1st floor) to earn your Swift and Xcode badges on Trailhead.

Continue Reading this post here  Salesforce

Jacob Lehrbaum

Leave a Reply

Your email address will not be published. Required fields are marked *