> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-22654f5b-docs-rn-guide-message-privately.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Setup

> Setup — CometChat documentation.

## Get your Application Keys

[Signup for CometChat](https://app.cometchat.com) and then:

1. Create a new app
2. Head over to the **API Keys** section and note the **Auth Key**, **App ID** & **Region**

<Tip>
  Minimum Requirement

  1. Xcode 12 (or Higher)
  2. iOS 11 or higher
</Tip>

***

## Add the CometChat Dependency

### CocoaPods

We recommend using [CocoaPods](https://cocoapods.org/), as they are the most advanced way of managing iOS project dependencies. Open a terminal window, move to your project directory, and then create a `Podfile` by running the following command.

<Warning>
  1. CometChatPro SDK supports installation through Cocoapods only. Currently, we are supporting Xcode 11.4 and higher.
  2. CometChatPro SDK includes video calling components. We suggest you run on physical devices to avoid errors.
</Warning>

<Tabs>
  <Tab title="Swift">
    ```bash theme={null}
    $ pod init
    ```
  </Tab>
</Tabs>

Add the following lines to the Podfile.

<Tabs>
  <Tab title="Swift">
    ```ruby theme={null}
    platform :ios, '11.0'
    use_frameworks!

    target 'MyApp' do
      pod 'CometChatPro', '2.4.2'
    end
    ```
  </Tab>
</Tabs>

<Note>
  2.4.1+ onwards, Voice & Video Calling functionality has been moved to a separate framework. In case you do not plan to use the calling feature, please add the Calling framework `pod 'CometChatCalls', '2.1.1'` in your app Podfile.
</Note>

And then install the `CometChatPro` framework through CocoaPods.

<Tabs>
  <Tab title="Swift">
    ```bash theme={null}
    $ pod install
    ```
  </Tab>
</Tabs>

Always get the latest version of `CometChatPro` by command

<Tabs>
  <Tab title="Swift">
    ```bash theme={null}
    $ pod update CometChatPro
    ```
  </Tab>
</Tabs>

### Request Authorization

Prepare your app for this requirement by providing justification strings. The justification string is a localizable message that you add to your app's `Info.plist` file to tell the user why your app needs access to the user's photo library, Camera, Microphone. Then, App prompts the user to grant permission for access, the alert displays the justification string you provided, in the language of the locale selected on the user's device. You can do this as follows:

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/7a4hqm7gLVRmX34O/images/0119d1bb-1623200477-7bdad6acb11779de4a98a154e785d56a.png?fit=max&auto=format&n=7a4hqm7gLVRmX34O&q=85&s=accd167974c82e10f9281e54c694f0b6" width="1020" height="362" data-path="images/0119d1bb-1623200477-7bdad6acb11779de4a98a154e785d56a.png" />
</Frame>

<Tabs>
  <Tab title="Info.plist">
    ```xml theme={null}
    <key>NSAppTransportSecurity</key>
      <dict>
    	  <key>NSAllowsArbitraryLoads</key>
    	  <true />
      </dict>
    <key>NSCameraUsageDescription</key>
    	<string>$(PRODUCT_NAME) need access to the camera in order to update your avatar</string>
    <key>NSPhotoLibraryUsageDescription</key>
    	<string>$(PRODUCT_NAME) need access to the Photo Library in order to send Media Messages</string>
    <key>NSMicrophoneUsageDescription</key>
    	<string>$(PRODUCT_NAME) need access to the Microphone in order to connect Audio/Video call </string>
    ```
  </Tab>
</Tabs>

### Setup Bitcode

You can set the Enable Bitcode setting to **YES** present in build settings in your XCode project.

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/_MYSdWhXnUkTkjEH/images/477193c3-1631809611-db96539a98643ad55b7950d86d4b6557.png?fit=max&auto=format&n=_MYSdWhXnUkTkjEH&q=85&s=cdb80371bbba202c0083b53a88e791ed" width="1238" height="123" data-path="images/477193c3-1631809611-db96539a98643ad55b7950d86d4b6557.png" />
</Frame>

<Warning>
  If you are using CometChat Pro SDK having the version less than 2.0.8, then you need to set **Enable Bitcode** to **NO**
</Warning>

### Swift Standard Libraries

`CometChatPro`framework build on Swift, you have to ensure the required libraries are embedded. This can be done by setting the `“Always Embed Swift Standard Libraries”` checkbox in your target’s build settings to “Yes”:

<Frame>
  <img src="https://www.cometchat.com/docs/assets/images/1623200430-15b0442a710f78a45dd01090dc6a32f1.png" />
</Frame>

### Set Header Search Path

Set the `Header Search Paths` to `$SDKROOT/usr/include/libxml2`.

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/le8ibYc8lBJsShSE/images/57d60afc-1631809733-acc69d5f571a8aac9ac8683e9f1ed0eb.png?fit=max&auto=format&n=le8ibYc8lBJsShSE&q=85&s=3bf45d8961977ed3d93554b3f572a034" width="861" height="389" data-path="images/57d60afc-1631809733-acc69d5f571a8aac9ac8683e9f1ed0eb.png" />
</Frame>

Excluded Architecture

<Warning>
  For Xcode 12 and above, we need to add arm64 in the excluded architecture of build settings as Apple supports only arm architecture for simulators and actual devices. No support provided for X86\_64 and i386 architectures.
</Warning>

### Setting for build for active architecture

<Tip>
  In Build Settings, enable active architecture to Yes
</Tip>

<Frame>
  <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/7a4hqm7gLVRmX34O/images/03d9b800-1631809819-9693b622c55029f8fe4480d4f7481b65.png?fit=max&auto=format&n=7a4hqm7gLVRmX34O&q=85&s=142fad995e440989e9d1c27d5c16c7ae" width="1646" height="624" data-path="images/03d9b800-1631809819-9693b622c55029f8fe4480d4f7481b65.png" />
</Frame>

***

## Initialize CometChat

The `init()` method initializes the settings required for CometChat. We suggest you call the method on app startup preferably in the `didFinishLaunchingWithOptions:` method of the `AppDelegate` class.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    import CometChatPro

    class AppDelegate: UIResponder, UIApplicationDelegate{
    {
       var window: UIWindow?
       let appId: String = "ENTER APP ID"
       let region: String = "ENTER REGION CODE"
        
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

    let mySettings = AppSettings.AppSettingsBuilder().subscribePresenceForAllUsers().setRegion(region: region).build()
            
      CometChat.init(appId: appId ,appSettings: mySettings,onSuccess: { (isSuccess) in
                if (isSuccess) {
                    print("CometChat Pro SDK intialise successfully.")
                }
            }) { (error) in
                    print("CometChat Pro SDK failed intialise with error: \(error.errorDescription)")
            }
            return true
        }
    }
    ```
  </Tab>

  <Tab title="Objective-C">
    ```objc theme={null}
    #import <CometChatPro/CometChatPro-Swift.h>

    @interface AppDelegate ()

    @end

    @implementation AppDelegate


    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
      
      NSString *region = @"REGION";
      NSString *appID = @"YOUR_APP_ID";
        
        AppSettingsBuilder *appSettingBuilder = [[AppSettingsBuilder alloc]init];
        AppSettings *appSettings = [[[appSettingBuilder subscribePresenceForAllUsers]setRegionWithRegion:region]build];
        
        [[CometChat alloc]initWithAppId: appID appSettings:appSettings onSuccess:^(BOOL isSuccess) {
            NSLog(isSuccess ? @"CometChat Initialize Success:-YES" : @"CometChat Initialize Success:-NO");
        } onError:^(CometChatException * error) {
            NSLog(@"Error %@",[error errorDescription]);
        }];
        return YES;
    }
    ```
  </Tab>
</Tabs>

Make sure you replace the `appId` with your CometChat **App ID** in the above code.

***

## Publishing to App Store

To publish your App on App Store please [follow this guide](/sdk/ios/2.0/publishing-app-on-appstore)
