# Install iOS SDK

## Manual Installation <a href="#manual-installation" id="manual-installation"></a>

[**Download the latest iOS SDK**](https://sdk.amity.co/sdk-release/ios/amitysdk.zip)

* Drag `AmitySDK.xcframework`, `Realm.xcframework` & `RealmSwift.xcframework` to your project.
* Make sure that `Copy items if needed` is selected and click Finish.
* Also switch the Embed section as `Embed & Sign`

The correct setup should look like this.

<figure><img src="/files/aSfqzWjI713wdFdWBPdU" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
You need to turn Rosetta mode on when using `AmitySDK` with arm64 simulator. To force the application to use Apple Rosetta environment with an Apple silicon Mac, refer to [this page](https://www.macworld.com/article/338843/how-to-force-a-native-m1-mac-app-to-run-as-an-intel-app-instead.html) for the instructions.
{% endhint %}

## Using Dependency Manager

`AmitySDK` supports installation via dependency managers.

* SwiftPM
* Cocoapods
* Carthage

### SwiftPM Installation <a href="#carthage-installation" id="carthage-installation"></a>

To integrate AmitySDK into your project via SwiftPM, please follow the instructions below.

* [Add a Package Dependency](https://developer.apple.com/documentation/swift_packages/adding_package_dependencies_to_your_app)

Enter the repository URL to search the package, and choose to install `AmitySDK`.

```
https://github.com/AmityCo/Amity-Social-Cloud-SDK-iOS-SwiftPM
```

{% hint style="warning" %}
Please specify the required version of the SDK using the"`Up to Next Major Version"`**`Dependency Rule`**` `` ``as shown in the image below. `
{% endhint %}

<figure><img src="/files/zCwtQZZiVAe2IjU6p4uC" alt=""><figcaption></figcaption></figure>

### Cocoapod & Carthage: <a href="#carthage-installation" id="carthage-installation"></a>

We have dropped support for Cocoapod & Carthage for `AmitySDK`. If you want to distribute AmitySDK through cocoapod & carthage, you can use the `xcframeworks` that we distribute through Swift Package Manager (SPM).\\

## Additional Steps for Amity Video

Amity Video requires the `AmitySDK` as dependencies. First, ensure you have installed `AmitySDK` as per the instructions [above](#manual-installation).

To use live video broadcast:

* Import `AmityLiveVideoBroadcastKit.xcframework` to your project.

To use a live video player:

### **For version 6.0.0 - 6.7.0**

* Import `AmityVideoPlayerKit.xcframework` to your project
* Download [`MobileVLCKit.xcframework`](https://s3-ap-southeast-1.amazonaws.com/ekosdk-release/ios-frameworks/5.1.0/MobileVLCKit.xcframework.zip), and import to your project.
* Switch each framework to `Embed & Sign`, except `MobileVLCKit` to `Do Not Embed`.

![For the project that uses both live video broadcast and live video player, the correct setup should look like this.](/files/-MdRm0aiDKTqUgITTTtM)

To install Swift Packages for Amity Video, please follow the instructions below.

* [Add a Package Dependency](https://developer.apple.com/documentation/swift_packages/adding_package_dependencies_to_your_app)

### **For version 6.8.0 and above**

* Import `AmityVideoPlayerKit.xcframework` to your project
* Download [`MobileVLCKit.xcframework`](https://sdk.amity.co/sdk-release/ios-frameworks/6.8.0/MobileVLCKit.xcframework.zip), and import to your project.
* Switch each framework to `Embed & Sign`, **all xcframeworks**.

<figure><img src="/files/akqpbf3DMZIfpZRPyxnp" alt=""><figcaption><p>For the project that uses both live video broadcast and live video player, the correct setup should look like this.</p></figcaption></figure>

## Amity Video with SwiftPM

To install Swift Packages for Amity Video, please follow the instructions below.

* [Add a Package Dependency](https://developer.apple.com/documentation/swift_packages/adding_package_dependencies_to_your_app)

### 1. Install AmityVideoBroadcast

To use live video broadcast functionalities. Enter the repository URL to search the package, and choose to install `AmityVideoBroadcast`.

```
https://github.com/AmityCo/Amity-Social-Cloud-SDK-iOS-VideoBroadcast-SwiftPM
```

Try it in your code

```swift
import AmityLiveVideoBroadcastKit
```

### 2. Install AmityVideoPlayer

To use live video player functionalities. Enter the repository URL to search the package, and choose to install `AmityVideoPlayer`.

```
https://github.com/AmityCo/Amity-Social-Cloud-SDK-iOS-VideoPlayer-SwiftPM
```

Try it in your code

```swift
import AmityVideoPlayerKit
```

{% hint style="warning" %}
If you selected "`Up to Next Major Version`" option for the **Dependency Rule**, you need to manually add the version.
{% endhint %}

## Using AmitySDK with Objective C Code

Starting with v6.0.0, AmitySDK for iOS is written in Pure Swift. Although its in pure Swift, you can still use it in Objective-C projects by making Mixed-Language Project.

We recommend you to integrate `AmitySDK` for iOS swift directly into your Objective-C project and use Swift language to call the SDK interfaces.

#### Mixed Language Project:

To make a mixed language project, create Swift files with necessary interfaces/methods which in turn interacts with `AmitySDK`. These interfaces should be exposed with `@objc` or `@objcMembers` attributes. Reference: [Swift Attributes](https://docs.swift.org/swift-book/ReferenceManual/Attributes.html#ID592)

When you add new Swift file into your Objective-C project, Xcode automatically generates a bridging header file. This bridging header exposes your Swift code to Objective C code. For more information you can refer to this guide by Apple: [Importing Swift into Objective-C](https://developer.apple.com/documentation/swift/importing-swift-into-objective-c)

```swift
// Example of a Swift file which contains a class to interact with AmitySDK.

@objc class SDKLoginManager: NSObject {

    let client: AmityClient?

    @objc init(apiKey: String) {
        self.client = try? AmityClient(apiKey: apiKey)
    }

    @objc func login(userId: String, displayName: String, authToken: String, completion: @escaping (Bool, Error?) -> Void) {
        self.client?.login(userId: userId, displayName: displayName, authToken: authToken, completion: completion)
    }
}
```

```swift
#import "ViewController.h"
#import "YourProjectName-Swift.h" // <- This import exposes above Swift file to your Objc project.

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)testSDKUsage {

    SDKLoginManager *loginManager = [[SDKLoginManager alloc] initWithApiKey:@"my-api-key"];
    [loginManager loginWithUserId:@"user-id" displayName:@"display-name" authToken:@"auth-token" completion:^(BOOL isSuccess, NSError * _Nullable error) {

        // Handle login completion here
    }];
}

@end
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.social.plus/getting-started/installation-and-authentication/install-ios-sdk.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
