πŸ“ Bolt / Developers / SDKs / iOS / iOS SDK Quickstart

iOS SDK Quickstart

Welcome to the Bolt iOS SDK! Our goal is to deliver the most innovative checkout experience possible — for both you and your shoppers. To get started, follow this quickstart guide to install the iOS SDK on your application. After that, you can customize your checkout to include payment methods such as Apple Pay.

Pre-Requisites

Explore the Bolt iOS SDK

This is an optional step and is not required for installing the Bolt iOS SDK.

  1. Install XCode.
  2. Clone the Bolt iOS SDK Repo: git clone https://github.com/BoltApp/bolt-ios-sdk.git
  3. In your terminal, navigate to cd bolt-ios-sdk and run open YourShopApp.xcworkspace.
  4. CHose CheckoutExample as the target in XCode and run it.

iOS SDK Set Up

1. Install the Bolt iOS SDK Library

Add a new source in your Podfile:

source 'https://github.com/BoltApp/podspecs.git'

Then, add a new target:

pod 'BoltCheckout'

After making these changes, your Podfile should look something like this:

source 'https://github.com/BoltApp/podspecs.git'
target 'YourShopApp' do
  //Comment out the next line if you don't want to use dynamic frameworks.
  use_frameworks!
  pod 'BoltCheckout'
end

When authenticating, be sure to use Github Generated Tokens instead of passwords.

Finally, install your Podfile again to set the SDK as a dependency in your project:

pod install

Congratulations! Bolt’s SDK is now a dependency in the project!

2. Import Bolt's SDK into the Source Code

In the view controller source file, where the merchant wants to include the checkout and apple pay button, the merchant must include Bolt.

A view controller manages a single root view and its potential many subviews. User interactions with that view hierarchy are handled by your view controller. In other words, the view controller acts as an intermediary between the views it manages and the data of your app.

Add the following line to the top of your view controller source file:

import BoltCheckout

3. Create a View Controller

In the viewDidLoad function of your controller, configure the needed view controller for your checkout. This can look something like:

let boltVC = Bolt().withApplePayButton().withCheckoutButton().checkoutPanel()

This will enable the Apple Pay and Bolt Checkout buttons to appear in your checkout view.

4. Integrate the Bolt View Controller

Finally, add the merchant’s instance of BoltCheckoutPanelViewController into their current view controller’s view hierarchy.

addChild(boltVC)
boltVC.didMove(toParent: self)

The boltVC (BoltCheckoutPanelViewController) controller controls a checkout panel view (BoltView) that has two buttons:

  • Checkout
  • Apple Pay

Merchants have to add Bolt’s checkout panel view to their view hierarchy. It can be added to any other view that can contain children.

stackView.addSubview(boltVC.view)

5. Configure environment type

There are two types of environments merchants may use when initializing the SDK:

  • sandbox - A staging environment
  • production - A production environment

The production environment is the automatic default. If no environment parameter is specified, the production environment is assumed.

Merchants can configure the type of environment during initialization using the inline parameters .sandbox and .production, as shown below.

Sandbox:

Bolt(environment: .sandbox).withCheckoutButton.checkoutPanel()

Production:

Bolt(environment: .production).withCheckoutButton.checkoutPanel()

6. Set View Constraints

Constraints allow you to create views that dynamically adjust to different size classes and positions, without having to manually update frames or positions.

boltVC.view.leadingAnchor.constraint(equalTo: superview.leadingAnchor).isActive = true
boltVC.view.trailingAnchor.constraint(equalTo: superview.trailingAnchor).isActive = true
// You may either define your own view height, or use the preferred height for checkout view
let height = boltVC.preferredVerticalLayoutHeight
boltVC.view.heightAnchor.constraint(equalToConstant: height).isActive = true

The merchant app should now include the Checkout button and the Apple Pay button. These buttons are both configured to perform completely and take users through the entire checkout process.

Next Steps

Next, you can move on to using the SDK to create the Bolt View Controller to manage and show both the Checkout and Apple Pay buttons.

If you’re not using Apple Pay, you can also move on to customizing the shopper’s checkout experience or enable the Bolt Checkout button.

πŸ‘Ž

How did we do?

πŸ“–On This Page