Integrate the SDK

Update time: 2023/02/09 03:53:39

This document describes how to integrate Instant Messaging SDK (NIM SDK) into your project.

Set up a development environment

iPhone or iPad devices with iOS 8.0 and later


Step 1: Create a new project (optional)

This step creates a new project. If you already integrate NIM SDK into an existing project, ignore this step 1. Launch Xcode and select File > New > Project in the upper left corner.
2. In the list that appears, select the iOS platform, and select App under Application.
3. Configure the new project and click Next.
Product Name and Organization Identifier are required.
4. Select the storage path and click Create to create a project.

Step 2: Integrate the SDK

You can integrate NIM SDK using the following two methods. Select one method as required.

  • Automatic integration of the NIM SDK using CocoaPods (recommended).

  • Manually integrate NIM SDK.

Integrate the SDK using CocoaPods

  1. After installing CocoaPods, run the following command in the project directory to create a Podfile.

    objcpod init
  2. Add the resources in the Podfile.

    Keywords for CocoaPods integration:

    Keyword Resources
    NIMSDK_LITE NIM SDK that has the NetEase Object Storage (NOS) capability by default.
    NIMSDK_LIET/FCS NIM SDK that has AWS S3 file storage capability by default
    NIMKit NIMSDK_LITE+NIM_iOS_UIKit+custom version third-party dependency
    NIMKit/Lite_Free NIMSDK_LITE+NIM_iOS_UIKit+unlimited third party dependency

    If you only need the instant messaging capabilities (NOS) and do not need the NIM_iOS_UIKit component, you can specify the setting in Podfile:

        pod 'NIMSDK_LITE' 
  3. Run the following command to update the local repository and view the version information. For the information about the newest version, see Changelog.

        pod search NIMSDK_LITE   //Search the resource version in the repository
        pod repo update // Update the local repository.
  4. Run the following command to install NIM SDK:

        pod install

Manual integration

  1. Download the required SDK.
Framework Description
NIMSDK Basic messaging capability
NIMNOS NOS file storage capabilitythat works with NIMSDK (not NIMFCS)
NIMFCS AWS S3 file storagecapability that works with NIMSDK (notNIMNOS)
:::note note
- NIMSDK must be used with NIMNOS or NIMFCS and cannot be used alone.
    - If your app serves users in China, use NIMSDK and NIMNOS Frameworks.
    - If users of your app are distributed out of China, use NIMSDK and NIMFCS Frameworks.
- NIMNOS and NIMFCS cannot be used together.
  1. Copy the decompressed framework files to the project folder.

  2. Select the TARGETS > Project Name > General > Frameworks, Libraries, and Embedded Content menu, add the corresponding framework files, and set the Embed property to Embed & Sign, so that the dynamic libraries and application signature are consistent. The SDK is imported.

What’s next

After the SDK is integrated, you must initialize the SDK.

Demo download

IM Demo is open sourced on GitHub. You can download the source code for reference.


Why packaging fails

If you integrate the SDK manually, packaging may fail because the library contain the emulator version. You must remove the emulator version before packaging

  1. Create the script in the specified directory, such as Supporting Files
  2. Add a process in Build Phases of New Run Script Phase type.
  3. Add the following content to the project. For example, /bin/sh "${SRCROOT}/NIMDemo/Supporting Files/".
    /bin/sh the path of your script.
  4. Copy the following content to the script.
    # Strip invalid architectures
    strip_invalid_archs() {
    echo "current binary ${binary}"
    # Get architectures for current file
    archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)"
    for arch in $archs; do
    if ! [[ "${ARCHS}" == *"$arch"* ]]; then
    if [ -f "$binary" ]; then
    # Strip non-valid architectures in-place
    lipo -remove "$arch" -output "$binary" "$binary" || exit 1
    stripped="$stripped $arch"
    if [[ "$stripped" ]]; then
    echo "Stripped $binary of architectures:$stripped"
    # This script loops through the frameworks embedded in the application and
    # removes unused architectures.
    find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
    FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
    echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"
    strip_invalid_archs "$FRAMEWORK_EXECUTABLE_PATH"
Was this page helpful?
  • Set up a development environment
  • Procedure
  • Step 1: Create a new project (optional)
  • Step 2: Integrate the SDK
  • Integrate the SDK using CocoaPods
  • Manual integration
  • What’s next
  • Demo download
  • FAQ
  • Why packaging fails