Skip to main content

CocoaPods

Learn how to add Shake to your iOS app using CocoaPods.

note

Not using CocoaPods yet? Follow their brief installation guide, then run pod init in the root of your project and you're done — let's move on.

note

Shake SDK is distributed as a binary package, more specifically an XCFramework. CocoaPods added support for XCFrameworks in the 1.9 beta release, so make sure your CocoaPods installation is running with version no lower than 1.9.

Create a new app on Dashboard

Visit your Shake Dashboard and add a new Native iOS app by clicking the + button in the sidebar. Once you're done, you're ready to proceed with the steps below.

Add Shake to your Podfile

Podfile
use_frameworks!
pod 'Shake'

Then, run the pod install command in your terminal. After the installation also run pod update Shake to be perfectly sure that you're using the latest Shake .

Initialize Shake

Initialize Shake in the didFinishLaunchingWithOptions callback of your AppDelegate. Make sure that your iOS application bundleId matches the application bundleId saved in the Shake dashboard. Replace your-api-client-id and your-api-client-secret with the actual values you have in your workspace administration:

AppDelegate.swift
import UIKit
import Shake
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
Shake.start(clientId: "your-api-client-id", clientSecret: "your-api-client-secret")
return true
}
}
note

Some of the Shake features use swizzling. To avoid swizzling conflicts, call Shake.start() before initializing other frameworks.

Build and run your project by selecting Run → Run in the menu bar.

Conditional initialization

We recommend initializing Shake in the entry point of your app. However, depending on your app, you'll want to initialize Shake just in a specific conditions, depending on your app data. You can do it as shown in the example below when your app data is available:

Main.swift
import UIKit
import Shake
class MainVC: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
title = "Main"
if User.isTester() {
Shake.start(clientId: "_client_id_", clientSecret: "_client_secret_")
}
}
}

Visit your Shake dashboard

Follow the instructions there to send your first feedback with Shake and you're all set.

SDK customizations

Now that Shake SDK is in your app and you have sent the first feedback for fun, everything else is optional. As the next step, try the three most popular SDK customizations: