Swiftpack.co -  mike4aday/SwiftlySalesforce as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
mike4aday/SwiftlySalesforce
The Swift-est way to build native mobile apps that connect to Salesforce.
.package(url: "https://github.com/mike4aday/SwiftlySalesforce.git", from: "v9.0.3")

Swiftly Salesforce

  

Swiftly Salesforce is the Swift-est way to build native mobile apps that connect to Salesforce:

Minimum Requirements

  • iOS 14.0
  • Swift 5.3
  • Xcode 12

Quick Start

Get up and running in a few minutes:

  1. Get a free Salesforce Developer Edition environment.
  2. Create a Connected App in your new environment. (Example)
  3. Add the Swiftly Salesforce package to your Xcode project with URL https://github.com/mike4aday/SwiftlySalesforce.git.

Check out this screenshot for an example Connected App definition. Note that the checkbox for "Require Secret for Refresh Token Flow" should not be selected.

Most of your interactions with Swiftly Salesforce will be via the ConnectedApp struct, which represents the Salesforce Connected App you created above. For example, you could query, insert, retrieve, update or delete Salesforce records using ConnectedApp's relevant convenience methods. Or, you could create your own struct that implements the Service protocol, and overrides the default property implementations or the buildRequest method. Then use your custom service as an argument to ConnectedApp's go method.

Sample App

Check out MySalesforceAccounts for a complete, working app that uses SwiftUI, Combine and Swiftly Salesforce to display the user's Salesforce account records. Though it's a relatively-trival app, it illustrates how to configure an app and quickly connect it to Salesforce. See especially MyAccountsLoader.swift, ContentView.swift and Salesforce.json.

Before you run the sample app, edit Salesforce.json and replace the temporary values for the consumer key and callback URL with those of your own Connected App.

Documentation

Swiftly Salesforce documentation

User Authorization

Swiftly Salesforce will automatically manage all required Salesforce authorization flows. If Swiftly Salesforce already has a valid access token in its secure store, it will include that token in the header of every API request. If the token has expired and Salesforce rejects the request, then Swiftly Salesforce will attempt to refresh the access token without bothering the user to re-enter the username and password. If Swiftly Salesforce doesn't have a valid access token, or is unable to refresh it, then Swiftly Salesforce will direct the user to the Salesforce-hosted login form.

You could modify this default authorization behavior if you don't want the user interrupted by the authentication form. Many methods have an argument, allowsLogin, which is true by default (example). But if you set allowsLogin to false, Swiftly Salesforce would attempt to refresh the token without interrupting the user, and if that attempt is unsuccessful the call would fail. The user would not be prompted for the username and password, and you could catch the resulting error and handle it as you see fit.

Questions, Suggestions & Bug Reports

GitHub

link
Stars: 117
Last commit: 5 days ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

1 week ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API