Skip to main content

Plug n Play Web3Auth on Native iOS (Swift, OpenLogin)


This tutorial will guide you to use openlogin-swift-sdk to integrate Web3Auth into your iOS application. OpenLogin is Web3Auth's hosted auth solution.

Source code of the example can also be found in the repository.


  • iOS 12+ (older version support coming soon)
  • Xcode 11.4+ / 12.x
  • Swift 4.x / 5.x


If you are using the Swift Package Manager, open the following menu item in Xcode:

File > Swift Packages > Add Package Dependency...

In the Choose Package Repository prompt add this url:

Getting Started

Authentication with In-App Web-based Flow (iOS 12+):

  1. Import OpenLogin into your project.
import OpenLogin
  1. Present the In-App Web-based Login modal.
.start {
switch $0 {
case .success(let result):
Signed in successfully!
Private key: \(result.privKey)
User info:
Name: \(
Profile image: \(result.userInfo.profileImage ?? "N/A")
Type of login: \(result.userInfo.typeOfLogin)
case .failure(let error):
print("Error: \(error)")


In order to use OpenLogin you need to provide your OpenLogin ClientId and which Network to run it.

  • Go to Torus Developer, create or open an existing Plug n Play project and copy your project ID, which is the ClientId.

In your application bundle add a plist file named OpenLogin.plist with the following information:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
<string>mainnet | testnet</string>

Next steps

See our API reference for more advanced usage.