In-App Purchases have become a very important part of our business. Adding them to an app can involve quite a bit of boilerplate code though. Today we'll look at SwiftyStoreKit, a framework from Andrea Bizzotto that can help.

SwiftyStoreKit provides a few static functions we can use to easily implement all the common In-App Purchase tasks like getting the info about our "products" from Apple, purchasing, restoring, and even receipt verification. Let's take a look:

SwiftyStoreKit.retrieveProductInfo("com.littlebitesofcocoa.products.volume1") { result in
  switch result {
    case .Success(let product):
      let priceString = NSNumberFormatter.localizedStringFromNumber(product.price, numberStyle: .CurrencyStyle)
      print("Product: \(product.localizedDescription), Price: \(priceString)")

    case .Error(let error): print("Error: \(error)")
  }
}

We pass in the product identifier, and supply a closure that can process the result. If successful, we use NSNumberFormatter (Bite #182) to print a nice looking summary of the product.

From here, we just need to wire up the other functions SwiftyStoreKit provides like purchaseProduct, restorePurchases, and verifyReceipt.

More info about SwiftyStoreKit can be found at git.io/swiftystorekit