--- title: Checkout Kit for Swift description: Learn how to integrate Checkout Kit using Swift. source_url: html: https://shopify.dev/docs/storefronts/mobile/checkout-kit/swift md: https://shopify.dev/docs/storefronts/mobile/checkout-kit/swift.md --- ExpandOn this page * [What you'll learn](https://shopify.dev/docs/storefronts/mobile/checkout-kit/swift#what-youll-learn) * [Requirements](https://shopify.dev/docs/storefronts/mobile/checkout-kit/swift#requirements) * [Step 1: Install the Checkout Kit as a package dependency](https://shopify.dev/docs/storefronts/mobile/checkout-kit/swift#step-1-install-the-checkout-kit-as-a-package-dependency) * [Step 2: Import the library](https://shopify.dev/docs/storefronts/mobile/checkout-kit/swift#step-2-import-the-library) * [Step 3: Present the checkout through a checkout URL or cart permalink](https://shopify.dev/docs/storefronts/mobile/checkout-kit/swift#step-3-present-the-checkout-through-a-checkout-url-or-cart-permalink) # Checkout Kit for Swift Checkout Kit is an open-source [Swift Package library](https://github.com/Shopify/checkout-sheet-kit-swift/blob/main) that allows you to integrate Shopify's checkout in your mobile app. To get started, see our [sample projects](https://github.com/Shopify/checkout-sheet-kit-swift/blob/main/Samples/README.md), or follow the steps below to integrate it into your own project. *** ## What you'll learn * Integrate Checkout Kit to your project * Present the checkout through a checkout URL or cart permalink *** ## Requirements * Swift 5.7+ * iOS SDK 13.0+ *** ## Step 1: Install the Checkout Kit as a package dependency ### Package.​swift ## Package.swift ```swift dependencies: [ .package(url: "https://github.com/Shopify/checkout-sheet-kit-swift", from: "3") ] ``` ### Xcode 1. Open your Xcode project 2. Navigate to `File` > `Add Package Dependencies…` 3. Enter `https://github.com/Shopify/checkout-sheet-kit-swift` into the search box 4. Click `Add Package` For more details on managing Swift Package dependencies in Xcode, please see [Apple's documentation](https://developer.apple.com/documentation/xcode/adding-package-dependencies-to-your-app). ### Cocoapods ## iOS ```swift pod "ShopifyCheckoutSheetKit", "~> 3" ``` For more information on CocoaPods, please see their [getting started guide](https://guides.cocoapods.org/using/getting-started.html). *** ## Step 2: Import the library After adding Checkout Kit as a dependency, you can import the library in your code: ## iOS ```swift import ShopifyCheckoutSheetKit ``` *** ## Step 3: Present the checkout through a checkout URL or cart permalink To present a checkout to the customer, your app must specify a checkout URL. To get this URL, you can use [Storefront GraphQL API](https://shopify.dev/docs/api/storefront) to build a cart and load its [checkout URL](https://shopify.dev/docs/api/storefront/2023-10/objects/Cart#field-cart-checkouturl). Or, you can provide a [cart permalink](https://shopify.dev/docs/apps/build/checkout/create-cart-permalinks). When using GraphQL to get a checkout URL, Shopify's [Mobile Buy SDK for iOS](https://github.com/Shopify/mobile-buy-sdk-ios) can simplify the development workflow, as shown in the following code sample: ## iOS ```swift import Buy let client = Graph.Client( shopDomain: "yourshop.myshopify.com", apiKey: "" ) let query = Storefront.buildQuery { $0 .cart(id: "myCartId") { $0 .checkoutUrl() } } let task = client.queryGraphWith(query) { response, error in let checkoutURL = response?.cart.checkoutUrl } task.resume() ``` `checkoutUrl` is a standard web checkout URL that can be opened in any browser. To present the checkout in your mobile app, call `present` on `ShopifyCheckoutSheetKit`. Pass in the checkout URL, along with other runtime configuration settings, as shown in this code: ## iOS ```swift import UIKit import ShopifyCheckoutSheetKit class MyViewController: UIViewController { func presentCheckout() { let checkoutURL: URL = // obtained from buyer's cart or cart permalink ShopifyCheckoutSheetKit.present(checkout: checkoutURL, from: self, delegate: self) } } ``` *** * [What you'll learn](https://shopify.dev/docs/storefronts/mobile/checkout-kit/swift#what-youll-learn) * [Requirements](https://shopify.dev/docs/storefronts/mobile/checkout-kit/swift#requirements) * [Step 1: Install the Checkout Kit as a package dependency](https://shopify.dev/docs/storefronts/mobile/checkout-kit/swift#step-1-install-the-checkout-kit-as-a-package-dependency) * [Step 2: Import the library](https://shopify.dev/docs/storefronts/mobile/checkout-kit/swift#step-2-import-the-library) * [Step 3: Present the checkout through a checkout URL or cart permalink](https://shopify.dev/docs/storefronts/mobile/checkout-kit/swift#step-3-present-the-checkout-through-a-checkout-url-or-cart-permalink)