All Collections
Installation
Mobile SDK Installation Guide for iOS
Mobile SDK Installation Guide for iOS
Sera Naz Ersoy avatar
Written by Sera Naz Ersoy
Updated over a week ago

Commented's Mobile SDK for iOS allows you to integrate Commented's commenting and collaboration features seamlessly into your iOS application. With this SDK, you can provide a collaborative environment for your app users to leave comments and feedback right within your mobile app.

Mobile SDK Installation for iOS: A Step-by-Step Guide

Follow these steps to install Commented's Mobile SDK on your iOS application:

Step 1: Install CocoaPods

1. Install Ruby:

First, you may need to install Ruby on your computer. To check if Ruby is installed, open the Terminal and run the following command:

ruby -v

If Ruby is not installed, you can install it from the official Ruby website or using a tool like Ruby Version Manager (RVM).

2. Install CocoaPods:

After installing Ruby, open the Terminal and use the following command to install CocoaPods:

gem install cocoapods

This command will download and install the latest version of CocoaPods.

3. Verify Successful Installation:

After CocoaPods is installed, verify the installation by running the following command:

pod --version

You should see the version number if CocoaPods was successfully installed.

Step 2: Install Commented Pod

1. Navigate to Your Project’s Root Directory:

First, you need to navigate to the root directory of the project where you want to use the Commented pod. You can do this in the Terminal using the cd command. For example, if your project is located in a directory called "MyProject," you can navigate to it with the following command:

cd /path/to/MyProject

Replace "/path/to/MyProject" with the actual path to your project's root directory. Once you're in the project's root directory, proceed to the next steps.

2. Add CocoaPods Podfile to Your Project:

Navigate to the root directory of the project where you want to use the Commented pod. Open the Terminal and use the following command to create a Podfile:

pod init

This command will create a file named Podfile in the root directory of your project.

3. Edit the Podfile:

Open the Podfile using a text editor and add the Commented pod as follows:

target 'YourProjectName' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!

# Pods for YourProjectName
pod 'Commented'
end

Replace 'YourProjectName' with the name of your project's name.

4. Include Post Install to Your Podfile:

Open the Podfile using a text editor and add the post install functions at the end of your Podfile as follows:

target 'YourProjectName' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!

# Pods for YourProjectName
pod 'Commented'
end

post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == 'SnapKit'
target.build_configurations.each do |config|
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'NO'
end
end
end
end

This Post Install method is important to be included in order to our SDK work properly. Otherwise SnapKit related crushes might be occurred.

5. Install the Pods:

Open the Terminal and use the following command to install the pods listed in your Podfile:

pod install --repo-update

We strongly recommend using --repo-update with your installation in order to get latest version of the Commented. This command will download the specified pods and integrate them into your project.

6. Use the Workspace:

After the pod install process is complete, CocoaPods will create a .xcworkspace file for your project. You should use this workspace to work on your project because the pods are included in this workspace.

Step 3: Start Using Commented

1. Initialize Commented

To use the "Commented" library in your Swift project, you need to import it at the top of your Swift files where you plan to use it. Open the AppDelegate.swift file and add the following import statement:

import Commented

In your project's AppDelegate.swift file, initialize the "Commented" library. Locate the application(_:didFinishLaunchingWithOptions:) function and add the following line of code just before the return true statement:

Commented.shared.start()

This line initializes the "Commented" library and ensures it is active when your app launches.

2. Initialize Commented in SceneDelegate (Troubleshooting):

This Step is optional. If you encounter issues with "Commented" not working, navigate to the SceneDelegate.swift file in your project. Import the "Commented" library by adding the following line at the top of the file:

import Commented

• Inside the scene(_:willConnectTo:options:) function, find the line with guard let _ = (scene as? UIWindowScene) else { return }. Replace the underscore (_) with windowScene as follows:

guard let windowScene = (scene as? UIWindowScene) else { return }

Below the modified line, add the following two lines of code to create a window and configure it for the "Commented" library:

let window = UIWindow(windowScene: windowScene)
Commented.shared.setupWindow(window: window)

These steps ensure that "Commented" is properly configured when using the SceneDelegate.

You have now successfully integrated Commented's Mobile SDK into your iOS app, enabling in-app comments and collaboration features for your users.

If you encounter any issues during the integration or have questions about using Commented's Mobile SDK in your iOS app, feel free to contact our support team. We're here to assist you and ensure a smooth integration process.


Did this answer your question?