{"id":1909,"url":"https://github.com/mike4aday/SwiftlySalesforce","last_synced_at":"2025-08-06T12:32:02.203Z","repository":{"id":42638954,"uuid":"49215320","full_name":"mike4aday/SwiftlySalesforce","owner":"mike4aday","description":"The Swift-est way to build native mobile apps that connect to Salesforce.","archived":false,"fork":false,"pushed_at":"2024-05-16T15:47:09.000Z","size":5012,"stargazers_count":136,"open_issues_count":8,"forks_count":43,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-12-06T05:03:30.477Z","etag":null,"topics":["api","asynchronous","combine","ios","ipados","mobile","oauth","oauth2","reactive","salesforce","salesforce-developers","salesforce-rest-api","spm","swift","swiftpackagemanager","swiftui"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mike4aday.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-01-07T16:13:58.000Z","updated_at":"2024-10-22T17:08:27.000Z","dependencies_parsed_at":"2024-01-08T10:17:03.301Z","dependency_job_id":"f82bcef4-4fd6-4d52-b42f-89fff376ca9f","html_url":"https://github.com/mike4aday/SwiftlySalesforce","commit_stats":null,"previous_names":[],"tags_count":59,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mike4aday%2FSwiftlySalesforce","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mike4aday%2FSwiftlySalesforce/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mike4aday%2FSwiftlySalesforce/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mike4aday%2FSwiftlySalesforce/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mike4aday","download_url":"https://codeload.github.com/mike4aday/SwiftlySalesforce/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228898283,"owners_count":17988652,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","asynchronous","combine","ios","ipados","mobile","oauth","oauth2","reactive","salesforce","salesforce-developers","salesforce-rest-api","spm","swift","swiftpackagemanager","swiftui"],"created_at":"2024-01-05T20:15:58.760Z","updated_at":"2024-12-09T13:30:34.985Z","avatar_url":"https://github.com/mike4aday.png","language":"Swift","funding_links":[],"categories":["SDK","Libs","Networking","API [🔝](#readme)"],"sub_categories":["Unofficial","API","Other free courses"],"readme":"\u003cimg src=\"https://mike4aday.github.io/SwiftlySalesforce/images/Swiftly-Salesforce-Logo.svg\" width=\"88px\"/\u003e \n\n# Swiftly Salesforce\n\n\"The Swift-est way to build native mobile apps that connect to [Salesforce](https://www.salesforce.com/products/platform/overview/).\"\n\n\u003cimg src=\"https://img.shields.io/badge/%20in-swift%205.5-orange.svg\"/\u003e\u0026nbsp;\u003cimg src=\"https://img.shields.io/cocoapods/p/SwiftlySalesforce.svg?style=flat\"/\u003e\u0026nbsp;\u003cimg src=\"https://img.shields.io/github/license/mike4aday/SwiftlySalesforce\"/\u003e\n\n* Written entirely in [Swift](https://developer.apple.com/swift/).\n* Very easy to install and update with [Swift Package Manager](https://developer.apple.com/documentation/swift_packages/adding_package_dependencies_to_your_app).\n* Built with Apple's new [Swift concurrency](https://developer.apple.com/news/?id=2o3euotz) model to simplify complex, asynchronous calls to the [Salesforce REST API](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/).\n* Designed for [SwiftUI](https://developer.apple.com/documentation/swiftui/), the modern, declarative way to build iOS apps.\n* Manages the Salesforce [user authorization flows](https://help.salesforce.com/articleView?id=sf.remoteaccess_oauth_flows.htm\u0026type=5) automatically.\n* Pair with [Core Data](https://developer.apple.com/documentation/coredata) for a complete offline mobile solution.\n* Simpler and lighter alternative to the Salesforce [Mobile SDK for iOS](https://github.com/forcedotcom/SalesforceMobileSDK-iOS).\n* See [what's new](./CHANGELOG.md) in this release.\n\n## Minimum Requirements\n* iOS 15.0\n* Swift 5.5\n* Xcode 13\n\n## Quick Start\nGet up and running in less than 5 minutes!\n\n1. **Get a free Salesforce Developer Edition:** You can sign up for a free developer environment (also called an \"organization\" or \"org\") [here](https://developer.salesforce.com/signup). It will never expire as long as you log in at least once every 6 months.\n\n2. **Create a Salesforce Connected App:** Create a new [Connected App](https://help.salesforce.com/articleView?id=sf.connected_app_create.htm\u0026type=5) in your developer environment. [This screenshot](https://mike4aday.github.io/SwiftlySalesforce/images/ConnectedAppDefinition.png) shows an example; you can copy the settings that I've entered. Be sure that \"Require Secret for Refresh Token Flow\" is *not* checked.\n\n3. **Add Swiftly Salesforce to your project:** Add the Swiftly Salesforce package to your Xcode project ([instructions](https://developer.apple.com/documentation/xcode/adding_package_dependencies_to_your_app)) with the URL https://github.com/mike4aday/SwiftlySalesforce.git.\n\n4. **Create a configuration file:** In your Xcode project, create an empty file named [`Salesforce.json`](https://github.com/mike4aday/MySalesforceAccounts/blob/51cda01bc5c867643a9ef5085ede05e91151dfda/MySalesforceAccounts/Salesforce.json) and add the following JSON text, replacing the placeholder text with the actual values for your Connected App's consumer key and callback URL:\n```json\n{\n    \"consumerKey\" : \"\u003cReplace with the consumer key from your Connected App definition\u003e\",\n    \"callbackURL\" : \"\u003cReplace with the callback URL from your Connected App definition\u003e\"\n}\n```\n\n5. **Connect to Salesforce:** Call [`Salesforce.connect()`](https://github.com/mike4aday/SwiftlySalesforce/blob/fa9b051a9c857b09ae17b091a5db7210fa1dedd4/Sources/SwiftlySalesforce/Salesforce.swift#L5) and you're ready to go! If you're using SwiftUI, you could call the following from your main application file and store the Salesforce connection in the environment. Swiftly Salesforce will automatically handle all the OAuth flows, authenticating users on their first use of your app and then silently refreshing their access tokens when required.\n\n```swift\n// MyApp.swift\nimport SwiftUI\nimport SwiftlySalesforce\n\n@main\nstruct MyApp: App {\n    var body: some Scene {\n        WindowGroup {\n            ContentView().environmentObject(try! Salesforce.connect())\n        }\n    }\n}\n```\n\nI expect that you'll find most of the methods you'll need in the file [`Connection+API.swift`](https://github.com/mike4aday/SwiftlySalesforce/blob/fc9a5cfd659537cdde34059df35e6b5a1f8f229d/Sources/SwiftlySalesforce/Connection+API.swift) but if you require more, you could create your own implementation of [`DataService`](https://github.com/mike4aday/SwiftlySalesforce/blob/fc9a5cfd659537cdde34059df35e6b5a1f8f229d/Sources/SwiftlySalesforce/DataService.swift) and override just the relevant methods. See the source files in the `Sources/SwiftlySalesforce/Services` folder for examples of [`DataService`](https://github.com/mike4aday/SwiftlySalesforce/blob/fc9a5cfd659537cdde34059df35e6b5a1f8f229d/Sources/SwiftlySalesforce/DataService.swift) implementations that I created.\n\nHere are some examples of using the `Connection` class' convenience methods:\n\n```swift\n// ContentView.swift\nimport SwiftUI\nimport SwiftlySalesforce\n\n//...\n@EnvironmentObject var salesforce: Connection\n\n//...\n// Query the current user's accounts\nlet queryResults: QueryResult\u003cRecord\u003e = try await salesforce.myRecords(type: \"Account\")\n\n// Search for a string in Salesforce records\nlet searchResults: [Record] = try await salesforce.search(sosl: \"FIND {Joe Smith}\")\n\n// Get info about the current user\nlet userInfo: Identity = try await salesforce.identity()\n\n// Retrieve all fields of an Account record\nlet account: Record = try await salesforce.read(type: \"Account\", id: \"0011Y00003HVMu4QAH\")\n\n// Retrieve all fields of an Account record and decode them into your own, custom Decodable instance\nlet account2: CustomAccount = try await salesforce.read(type: \"Account\", id: \"0011Y00003HVMu4QAH\") \n\n// Insert a new record\nlet recordID: String = try await salesforce.create(type: \"Account\", fields: [\"Name\": \"Acme Corp.\"]\n\n// Update a record\ntry await salesforce.update(type: \"Account\", id: \"0011Y00003HVMu4QAH\", fields: [\"BillingCity\": \"Austin\"])\n\n// Get metadata about any Salesforce object, including custom fields, labels, validation rules, etc.\nlet accountMetadata = try await salesforce.describe(\"Account\")\n```\n\n## User Authorization\nSwiftly Salesforce will automatically manage all required Salesforce [authorization flows](https://help.salesforce.com/articleView?id=sf.remoteaccess_oauth_flows.htm\u0026type=5). 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.\n\n## Sample App\nCheck out [MySalesforceAccounts](https://github.com/mike4aday/MySalesforceAccounts) for a complete, working app that uses [SwiftUI](https://developer.apple.com/documentation/swiftui/), [Swift concurrency](https://developer.apple.com/news/?id=2o3euotz) 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.\n\nBefore you run the sample app, edit [Salesforce.json](https://github.com/mike4aday/MySalesforceAccounts/blob/51cda01bc5c867643a9ef5085ede05e91151dfda/MySalesforceAccounts/Salesforce.json) and replace the temporary values for the consumer key and callback URL with those of your own Connected App. \n\n## Questions, Suggestions \u0026 Bug Reports\n* Open a [GitHub issue](https://github.com/mike4aday/SwiftlySalesforce/issues/new)\n* Send me a direct message on Twitter [@mike4aday](https://twitter.com/mike4aday)\n* Send me a message on LinkedIn [in/mike4aday](https://www.linkedin.com/in/mike4aday)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmike4aday%2FSwiftlySalesforce","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmike4aday%2FSwiftlySalesforce","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmike4aday%2FSwiftlySalesforce/lists"}