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.
- Install CocoaPods.
- If you plan to install our Apple Pay integration, ensure you have meet all requirements listed in our enable Apple Pay for Shoppers article.
- Speak to your merchant to…
Explore the Bolt iOS SDK
This is an optional step and is not required for installing the Bolt iOS SDK.
- Install XCode.
- Clone the Bolt iOS SDK Repo:
git clone https://github.com/BoltApp/bolt-ios-sdk.git
- In your terminal, navigate to
cd bolt-ios-sdkand run
CheckoutExampleas 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:
Then, add a new target:
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:
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:
3. Create a View Controller
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)
BoltCheckoutPanelViewController) controller controls a checkout panel view (BoltView) that has two buttons:
- 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.
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
.production, as shown below.
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.