iOS Quickstart

Welcome to mParticle! Let’s send your first event.

Step 1: Generate your API key

Open your workspace and generate iOS API credentials on the Setup page.

Step 2: Add the SDK to your project

You can add the SDK via CocoaPods or Carthage.


Specify our SDK in your Podfile:


target '<Your Target>' do
    pod 'mParticle-Apple-SDK', '~> 7.0'


Specify our SDK in your Cartfile:

github "mparticle/mparticle-apple-sdk" ~> 7.0

Step 3: Initialize the SDK

import mParticle_Apple_SDK

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

    //initialize mParticle
    let options = MParticleOptions(key: "YOUR_API_KEY",
                                         secret: "YOUR_API_SECRET")
    options.environment = .development   
    MParticle.sharedInstance().start(with: options)
    return true
// Assumes the SDK has been included as a dynamic library
// Requires "Enable Modules (C and Objective-C)" in pbxproj
@import mParticle_Apple_SDK; 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    //initialize mParticle
    MParticleOptions *options = [MParticleOptions optionsWithKey:@"YOUR_API_KEY"
    options.environment = MPEnvironmentDevelopment;
    [[MParticle sharedInstance] startWithOptions:options];
    return YES;

Step 4: Verify your installation

Go to your Live Stream and watch new Session events come in as you launch your app in the emulator.

Next Steps

πŸŽ‰πŸŽ‰πŸŽ‰ Congrats on sending your first event to mParticle!

Some ideas on what to do next: Some ideas on what to do next:

Was this page helpful?