目录

Integrating the HMS Core SDK into the Xcode Project in Cocoapods Mode

Procedure

1. Add the AppGallery Connect configuration file of the app to your XCode project.

a. Sign in to AppGallery Connect and select My projects.

b. Find your app project and click the app that needs to integrate the HMS Core SDK.

c. Go to Project Setting > Convention. In the App information area, download the agconnect-services.plist file.

d. Copy the agconnect-services.plist file to the app's root directory of your Xcode project.

Note:

(1) Before obtaining the agconnect-services.plist file, ensure that you have enabled the advanced analytics service. For details, please refer to Enabling Advanced Analytics.

(2) If you have made any changes on the Project setting page, such as setting the data storage location and enabling or managing APIs, you need to download the latest agconnect-services.plist file and replace the existing file in the app's root directory.

2. Edit the Podfile file.

Add pod 'HiAnalytics', that is, the dependency for pod.

Example Podfile file:


  1. # Uncomment the next line to define a global platform for your project
  2. # platform :ios, '9.0'
  3. target 'hmsAnalyticsKitDemo' do
  4.  # Comment the next line if you don't want to use dynamic frameworks
  5.  use_frameworks!
  6.  # Pods for hmsAnalyticsKitDemo
  7.   pod 'HiAnalytics'
  8.  target 'hmsAnalyticsKitDemoUITests' do
  9.    # Pods for testing
  10.  end
  11. end

3. Run the pod install command to install the pod.

  1. $ pod install

Integrating the HMS Core SDK into the Xcode Project Manually

Downloading the SDK

1. Download HUAWEI Analytics Kit SDK and the SDKs on which it depends. For details, please refer to Integration Without CocoaPods.

SDKDescriptionRemarks

AGConnectCore-x.x.x.x.zip

AppGallery Connect framework package.

The SDK is mandatory.

AGConnectCredential-x.x.x.x.zip

AppGallery Connect gateway authentication package.

The SDK is mandatory.

HMSFoundation-x.x.x.x.zip

Task package.

The SDK is mandatory.

Decompress the downloaded packages.

2. Choose Add Files to project name to import all framework libraries to your workspace.

a. Right-click and choose Add Files to project name, and then click Select.

Note:
The framework libraries to be imported must be located in the same drive as your workspace. If they are not in the same drive, select Copy items if needed and Create groups to copy the project files of the framework libraries to the workspace.

b. On the General page, click + to add the framework libraries.

Note:
The framework libraries provided by the SDK are all static libraries. When adding these libraries, select Do not Embed.

Adding Libraries of Resource Files and Modifying the Project Configuration

1. Add the resource files.

On the Build Phases page, click + to add the libraries that contain the HiAnalytics.bundle and AGCResources.bundle resource files to Copy Bundle Resources.

Resource FileLibrary

HiAnalytics.bundle

HiAnalytics

AGCResources.bundle

Agconnect-credential

2. Modify the project configuration.

a. On the Build Settings page, add the -ObjC linker flag to Other Linker Settings.

  1. -ObjC

b. If you are using the Swfit language, also set Always Embed Swift Standard Libraries to Yes on the Build Settings page.