Uncategorized

Integrating the Mixpanel iOS SDK without CocoaPods

Note: Installing SDK version 2.6.0 or later from source has been known to cause build errors related to bad Framework linkage. If you encounter these errors, please install using CocoaPods.

To help users stay up to date with the latest versions of our iOS SDK, we always recommend installing our SDK with CocoaPods, which simplifies version updates and dependency management. For integration with CocoaPods, check out our documentation. However, there are cases where users can’t use CocoaPods. Fortunately, integrating our iOS SDK without CocoaPods is a breeze and can be done in just a few steps!

If you are looking to integrate without Cocoapods in Swift, please jump to later in this guide.

Objective-C

Follow the below steps to integrate the iOS library from source with an Objective-C project.

Step 1: Clone the SDK

Git clone the latest version of “mixpanel-iphone” to your local machine using the following code in your terminal:

git clone https://github.com/mixpanel/mixpanel-iphone.git

If you don’t have git installed, get it here.

Step 2: Add the SDK to your app!

Add the “Mixpanel” folder from the “mixpanel-iphone” to your XCode project’s folder:

And drag and drop the Mixpanel folder into your XCode Project Workspace:

Step 3: Import All dependencies

Add all dependencies of the Mixpanel SDK to your app. The full list of necessary frameworks and libraries on lines 16-17 in the “Mixpanel.podspec” file in the “mixpanel-iphone” directory:

Step 4: Integrate!

Import “Mixpanel.h” into AppDelegate.m, and initialize Mixpanel within `application:didFinishLaunchingWithOptions:`

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [Mixpanel sharedInstanceWithToken:MIXPANEL_TOKEN];
}

 

Start tracking

You’re done! You’ve successfully integrated the Mixpanel SDK into your app. To stay up to speed on important SDK releases and updates, subscribe to the mp-dev Google group or watch the iOS repository on Github.

Swift

Follow the below steps to integrate the iOS library from source with a Swift project.

Step 1: Clone the SDK

Git clone the latest version of “mixpanel-iphone” to your local machine using the following code in your terminal:

git clone https://github.com/mixpanel/mixpanel-iphone.git

If you don’t have git installed, get it here.

Step 2: Add the SDK to your app!

Drag and drop the “Mixpanel.xcodeproj” project file from “mixpanel-iphone” into Xcode:

Step 3: Import All dependencies

Import the “Mixpanel.framework” file as a dependency of your Xcode project:

Step 4: Integrate!

Import “Mixpanel” into AppDelegate.swift, and initialize Mixpanel within `application:didFinishLaunchingWithOptions:`

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        let mixpanel = Mixpanel.sharedInstanceWithToken(MIXPANEL_TOKEN);
}

 

Start tracking

You’re done! You’ve successfully integrated the Mixpanel SDK into your app. To stay up to speed on important SDK releases and updates, subscribe to the mp-dev Google group or watch the iOS repository on Github.

Have any questions? Reach out to support@mixpanel.com to speak to someone smart, quickly.

Get the latest from Mixpanel
This field is required.