Getting Started

This guide will help you to get started with the SDK. The SDK is a set of tools that allows you to interact with the API.


Integrating the SDK

Install CocoaPods

  1. Install CocoaPods (if not installed):
    sudo gem install cocoapods
    
  2. Navigate to your project folder in Terminal:
    cd /path/to/YourProject
    
  3. Initialize CocoaPods:
    pod init
    

Configure Podfile

Edit the generated Podfile:

platform :ios, '15.5'

target 'YourAppTargetName' do
  use_frameworks!
  use_modular_headers!

  # InstaVision SDK pod (replace with the latest version tag)
  pod 'IVSDK', :git => 'git@github.com:InstaViewAI/IVSDK-iOS.git', :tag => '1.0.0'
end

Install Pods

Run:

pod install

Then, always open the .xcworkspace file (not .xcodeproj).


Initialize InstaSDK

Add InstaSDK configuration to your app.

If using UIKit AppDelegate:

import UIKit
import IVSDK

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        InstaSDK.shared.configure(partnerId: AppConfig.partnerId)
        switch AppEnvironment.environment {
        case .dev:
            InstaSDK.shared.setEnvironment(.dev)
        case .staging:
            InstaSDK.shared.setEnvironment(.staging)
        case .prod:
            InstaSDK.shared.setEnvironment(.production)
        }
        let serverRegion = ServerRegion.us
        InstaSDK.shared.setRegion(serverRegion)
        return true
    }
}

If using SwiftUI lifecycle:

import SwiftUI
import IVSDK

@main
struct YourApp: App {
    init() {
        InstaSDK.shared.configure(partnerId: AppConfig.partnerId)
        switch AppEnvironment.environment {
        case .dev:
            InstaSDK.shared.setEnvironment(.dev)
        case .staging:
            InstaSDK.shared.setEnvironment(.staging)
        case .prod:
            InstaSDK.shared.setEnvironment(.production)
        }
        let serverRegion = ServerRegion.us
        InstaSDK.shared.setRegion(serverRegion)
    }

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