Skip to content

Install the Swift SDK

Add the MailJawn Swift SDK to your iOS or macOS app to collect subscribers directly from your app. The SDK automatically captures device info, app version, and locale alongside each subscriber.

Requirements

  • iOS 15.0+ or macOS 12.0+
  • Xcode with Swift Package Manager

Add the Package

  1. In Xcode, go to File > Add Package Dependencies...
  2. Enter the MailJawn SDK package URL:

    https://github.com/AcmeSoftware/mailjawn-swift-sdk
    
  3. Select your version rule and add the package to your target.

Configure the SDK

Initialize MailJawn as early as possible in your app's lifecycle — in your App init or AppDelegate:

import MailJawn

@main
struct MyApp: App {
    init() {
        MailJawn.configure(
            apiKey: "mj_your_api_key_here",
            projectId: "your-app-uuid-here"
        )
    }

    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

Replace apiKey with the API key you created in the previous step and projectId with your app's UUID.

Identify Users

After a user signs in to your app, call identify to associate them with a local user ID:

MailJawn.identify(userId: "user-123")

Then set their email to register them as a subscriber in MailJawn:

MailJawn.setEmail("user@example.com")

That's the minimum integration — the SDK handles batching, retries, and device metadata automatically.

Tip

Call MailJawn.reset() when a user logs out to clear local state.

Optional: Set Custom Properties

You can attach custom fields to subscribers for use in segments and template variables:

MailJawn.setUserProperties([
    "plan": "pro",
    "signup_source": "onboarding"
])

For the full API reference, see Swift SDK Reference. If you're not using Swift, see the REST API for a platform-agnostic alternative.

Next

Continue to Import Subscribers, or skip ahead to Send Your First Campaign if you're ready to send.