Magic SMS for iOS

Magic SMS for iOS

New to Magic?

Create a fully-functional Magic auth demo in minutes.

Build a demo

Reference for the Magic SDK for iOS:


The Magic SDK for iOS is your entry-point to secure, passwordless authentication for your mobile app. This guide will cover some important topics for getting started with iOS APIs and to make the most of Magic's features.

Magic can support either server-based or serverless web applications. It is up to the developers to implement the Admin SDK to validate the DID Token.

#Swift Package Manager Installation

1. In Xcode, select File > Add Packages... and enter `` as the repository URL.

2. Select `Up to Next Major Version 3.0.0`

3. Don't forget to add the libraries to your Package Dependencies

4. When it's been added to your dependencies, you're all set!

#Cocoapods Installation

It's easy to install Magic SDK if you manage your iOS dependencies using CocoaPods. If you don't have an existing Podfile, run the following command to create one:

$ pod init

Add pod 'MagicSDK' to your Podfile:

target 'TARGET_NAME' do

  pod 'MagicSDK'

  # Required for XCFramework
  post_install do |installer|
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'


Run the following command:

$ pod install

To update pods to the latest:

$ pod update

#Create an SDK Instance

All the examples are written in Swift.

import UIKit
import MagicSDK

class AppDelegate: UIResponder, UIApplicationDelegate {

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

        // assign the newly created Magic instance to shared property
        Magic.shared = Magic(apiKey: "API_KEY")

        // do any other necessary launch configuration
    return true

#Make a Request

let config = LoginWithSmsConfiguration(phoneNumber: self.phoneInput.text!)

magic.auth.loginWithSMS(configuration, response: { response in
    guard let result = response.result else { return print("Error:", response.error.debugDescription) }
    print("Result", result)

Once the authentication request is complete, the closure will be executed with either success or failure state in the result. If you choose to return as a promise, the promise will resolve with success state or reject when failure state is reached.

Server-side SDKs?

Integrate Magic with your existing backend.

Did you find what you were looking for?