The article background

3. Record of problems encountered in the integration of X series SDK

There is no way to directly use a remote repository for configuration Settings for a privatized deployment when integrated into a Swift project

  • Only the SDK is available, and podSpecs and privatized modifications need to be made by the user.

Article Content Outline

  • Fix Swift project: privatized configuration Settings cannot be referenced

    • For reference only
  • Address the HyphenateChat component company’s internal repository CocoaPods managed reference

    • Podspec has been uploaded here :github.com/DevDragonLi…

Fix Swift project: privatized configuration Settings cannot be referenced

  • The hyphenatechat. framework file consists of the following files
.├ ── Bass ├─ Info. ├─ tempo 2 Directories, 2 filesCopy the code
  • Hyphenatechat.h exposes accessible files as follows
//  HyphenateChat.h
//  HyphenateChat
#import <HyphenateChat/EMClient.h>
#import <HyphenateChat/EMClientDelegate.h>
#import <HyphenateChat/EMMultiDevicesDelegate.h>
Copy the code

Accessible and callableEMOptions+PrivateDeployThe following Settings are completed

The official private cloud configuration instructions: docs-im.easemob.com/im/ios/othe…

Because Swift is not introduced by default, it cannot be used directly. The solution is as follows

  • [1] : New classification of Swift project, corresponding to restServer, chatServer and other attributes

    • If other projects are used, the configurations need to be added for N times.
  • [2] : Upgrade SDK, not applicable to remote version

    • Pod Hook post-install header configuration (EMOptions+PrivateDeploy reference)
    • Modify hyphenatechat. h To add a configuration reference

	  let emOptions = EMOptions(appkey:"Key")
        emOptions?.restServer = "https://private.easemob.com"
        emOptions?.chatServer = "private-previe.easemob.com"
        emOptions?.chatPort = 000
        emOptions?.logLevel = EMLogLevelWarning
        EMClient.shared().initializeSDK(with: emOptions)
Copy the code

The solution is as follows

Hyphenatechat.h Exposed accessible files added EMOptions+PrivateDeploy.

  • Other undisclosed capabilities are also addressed in the same way.
#import <HyphenateChat/EMClient.h>
#import <HyphenateChat/EMClientDelegate.h>
#import <HyphenateChat/EMMultiDevicesDelegate.h>
#import <HyphenateChat/EMOptions+PrivateDeploy.h>

Copy the code

Address the HyphenateChat component company’s internal repository CocoaPods managed reference

The background is as follows

  • Introduced in Pod mode, no hyphenatechat. Podspec file is available.

The solution is as follows

  • Any project normal way to introduce HyphenateChat
  • Execute this command:pod cache list
HyphenateChat:
  - Version: 3.8.7
    Type:    External
    Spec:    /Users/dragonli/Library/Caches/CocoaPods/Pods/Specs/External/HyphenateChat/2943ed8b75a4403c3e6452f8bc46b87e.podspec.json
    Pod:     /Users/dragonli/Library/Caches/CocoaPods/Pods/External/HyphenateChat/1c4a1511a149c9179b56aabe82e1dba9-07c43
Copy the code
  • findHyphenateChat/2943ed8b75a4403c3e6452f8bc46b87e.podspec.jsonFile, as follows
{
  "name": "HyphenateChat",
  "version": "3.8.7",
  "summary": "An Objective-C client for IM service",
  "description": "HyphenateChat is a cloud-based PaaS (Platform as a Service) for Mobile Instant Messaging (MIM). We provide in-app messaging features such as one-to-one chat, group chat, voice message, picture/video/file sharing, location sharing, real-time voice/video calling, etc.",
  "homepage": "http://www.easemob.com/",
  "license": {
    "type": "MIT",
    "file": "LICENSE"
  },
  "authors": {
    "IM SDK ": "[email protected]"
  },
  "source": {
    "git": "[email protected]/iOS/Hyphenate.git",
    "tag": "3.8.7"
  },
  "platforms": {
    "ios": "11.0"
  },
  "pod_target_xcconfig": {
    "VALID_ARCHS": "arm64 x86_64",
    "EXCLUDED_ARCHS[sdk=iphonesimulator*]": "arm64"
  },
  "user_target_xcconfig": {
    "EXCLUDED_ARCHS[sdk=iphonesimulator*]": "arm64"
  },
  "xcconfig": {
    "OTHER_LDFLAGS": "-ObjC"
  },
  "ios": {
    "vendored_frameworks": "Framework/3.8.7/*.framework"
  }
}

Copy the code
  • Create a newHyphenateChat.podspec, refer to the above description, corresponding to the following form can be written (the following can be used directly, can be transformed into the corresponding Repo address)
Pod: : Spec. New do | s | s.n ame = 'HyphenateChat' s.v ersion = '3.8.7' s.s ummary = 'An Objective - C client for IM service' s.description = "HyphenateChat is a cloud-based PaaS (Platform as a Service) for Mobile Instant Messaging (MIM). We provide in-app messaging features such as one-to-one chat, group chat, voice message, picture/video/file sharing, location sharing, real-time voice/video calling, etc." s.homepage = 'http://www.easemob.com/' s.license = { :type => 'MIT', :file => 'LICENSE' } s.author = { 'IM SDK ' => '[email protected]' } s.source = { :git => '[email protected]/iOS/HyphenateChat. Git, To_s} s.iso. Deployment_target = '11.0' s.pron_target_xcconfig = {'VALID_ARCHS' => 'arm64 x86_64', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' } s.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64'} s.xcconfig = {'OTHER_LDFLAGS' => '-objc'} s.ios.vendored_frameworks = 'Framework/3.8.7/*.framework' endCopy the code