# 集成/制作DCloudUTSExtAPI

参考demo中的DCloudUTSExtAPI工程

# 新建原生工程

  1. 启动Xcode,点击File->New->Project,选择Framework点击Next
  2. Product Name中填写DCloudUTSExtAPILanguage选择为Objective-C,点击Next即可完成创建

你可以选择新建工程或直接使用demo中的DCloudUTSExtAPI工程

# 工程环境设置

Target -> General -> Minimum Deployments 选择 12.0

Target -> Build Settings -> Mach-O Type 设置为Dynamic Library

Target -> Build Settings -> Other Linker Flags 中添加-ObjC, 字母o和c大写

Target -> Build Settings -> Enable Module Verifier 设置为NO

Target -> Build Settings -> Build Libraries for Distribution 设置为YES

Target -> Build Settings -> Framework Search Paths 中添加SDK的Libs目录(操作方法:双击展开Framework Search PathsSDK/Libs文件夹拖入即可)

# 配置基础模块(必须)

将以下源文件(SDK/ExtApiSrc 目录下)、依赖库(SDK/Libs 目录下)添加到DCloudUTSExtAPI工程中,并将依赖库均设置为Do Not Embed

源文件 依赖库 资源文件
UTSOC.h
UTSOC.mm
uni-getAppAuthorizeSetting-index.swift
uni-getAppBaseInfo-index.swift
uni-getDeviceInfo-index.swift
uni-getSystemInfo-index.swift
uni-getSystemSetting-index.swift
uni-openAppAuthorizeSetting-index.swift
uni-prompt-index.swift
uni-rpx2px-index.swift
uni-storage-index.swift
uni-theme-index.swift
uni-getElementById-DCUniGetElementById.swift
uni-getElementById-index.swift
uni-crash-index.swift
uni-crash-UniCrashManager.swift
uni-privacy-index.swift
uni-dialogPage-index.swift
uni-dialogPage-native.swift
uni-event-index.swift
uni-event-native.swift
uni-exit-index.swift
DCloudUniappRuntime.xcframework
DCloudUTSFoundation.xcframework
DCUniToast.xcframework
DCloudAlertController.xcframework
KSCrash.xcframework
storage.framework
uts-config.json

# 配置其他模块(可选)

根据资源文件中的manifest.json文件包含的模块名称,选择以下源文件(SDK/ExtApiSrc 目录下)、依赖库(SDK/Libs 目录下)添加到DCloudUTSExtAPI工程中,依赖库均设置为Do Not Embed

模块名称 源文件 依赖库 系统依赖库
uni-createWebviewContext uni-createWebviewContext-index.swift
uni-getProvider uni-getProvider-index.swift
uni-network uni-network-index.swift
uni-getNetworkType uni-getNetworkType-index.swift
uni-websocket uni-websocket-index.swift websocket.xcframework
Starscream.xcframework
uni-canvas DCloudUniCanvas.xcframework
uni-media uni-media-index.swift DCloudMediaPicker.xcframework AssetsLibrary
Photos
AVFoundation
CoreServices
CoreFoundation
CoreGraphics
CoreImage
GLKit
MetalKit
MobileCoreServices
QuartzCore
ImageIO
MediaPlayer
CoreText
uni-payment-alipay uni-payment-alipay-index.swift
uni-payment-index.swift
AlipaySDK.xcframework c++
z
SystemConfiguration
CoreTelephony
QuartzCore
CoreText
CoreGraphics
CFNetwork
CoreMotion
uni-payment-wxpay uni-payment-wxpay-index.swift
uni-payment-index.swift
libWeChatSDK.a CoreGraphics
WebKit
Security
uni-virtualPayment uni-virtualPayment-index.swift
uni-virtualPayment-ProductService.swift
uni-virtualPayment-PurchaseService.swift
uni-virtualPayment-Types.swift
uni-virtualPayment-UniProduct.swift
uni-virtualPayment-UniPurchase.swift
uni-virtualPayment-UniStoreKit+Closure.swift
uni-virtualPayment-UniStoreKit.swift
StoreKit
uni-getLocation-system uni-getLocation-system-index.swift
uni-getLocation-index.swift
uni-getLocation-tencent uni-getLocation-tencent-index.swift
uni-getLocation-index.swift
TencentLBS.framework libz.1.2.5.tbd
uni-video uni-video-index.swift DCUniVideo.xcframework、IJKMediaFrameworkWithSSL.xcframework、UniDCSVProgressHUD.xcframework
uni-push uni-push-index.swift GTCommonSDK.xcframework
GTSDK.xcframework
ZXSDK.framework
c++
resolv
z
sqlite3
MobileCoreServices
Security
SystemConfiguration
CoreTelephony
AVFoundation
UserNotifications
AdSupport
uni-verify uni-verify-index.swift
uni-network-index.swift
GTCommonSDK.xcframework
GeYanSdk.xcframework
resolv.9
c++
z
sqlite3.0、WebKit
CoreFoundation
Network
AdSupport
uni-ad uni-ad-index.swift DCUniAdFoundation.xcframework
uni-facialRecognitionVerify uni-facialRecognitionVerify-index.swift AliyunFaceAuthFacade.framework
AliyunMobileRPC.framework
AliyunOSSiOS.framework
APBToygerFacade.framework
APPSecuritySDK.framework
BioAuthAPI.framework
BioAuthEngine.framework
deviceiOS.framework
DTFIdentityManager.framework
DTFSensorServices.framework
DTFUIModule.framework
DTFUtility.framework
MPRemoteLogging.framework
ToygerNative.framework
ToygerService.framework
c++
z
resolv
c++.1
c++abi
z.1.2.8
Accelerate
AssetsLibrary
QuartzCore
CoreFoundation
CoreLocation
ImageIO
CoreMedia
CoreMotion
AVFoundation
WebKit
AudioToolbox
CFNetwork
MobileCoreServices
SystemConfiguration
CoreTelephony
QuartzCore
CoreGraphics、AdSupport
uni-cloud-client uni-websocket-index.swift
uni-network-index.swift
uni-media-index.swift
DCloudMediaPicker.xcframework AssetsLibrary
Photos
AVFoundation
CoreServices
CoreFoundation
CoreGraphics
CoreImage
GLKit
MetalKit
MobileCoreServices
QuartzCore
ImageIO
MediaPlayer
CoreText
uni-map-tencent uni-map-tencent-animation-AnimationLocation.swift
uni-map-tencent-circle-DCCircle.swift
uni-map-tencent-circle-DCCircleModel.swift
uni-map-tencent-control-DCControl.swift
uni-map-tencent-control-DCControlModel.swift
uni-map-tencent-DCLatLng.swift
uni-map-tencent-ground-DCGroundOverlayModel.swift
uni-map-tencent-IInternalMap.swift
uni-map-tencent-index.swift
uni-map-tencent-marker-DCMakerModel.swift
uni-map-tencent-marker-DCMarker.swift
uni-map-tencent-polygon-DCPolygon.swift
uni-map-tencent-polygon-DCPolygonModel.swift
uni-map-tencent-polyline-DCPolyline.swift
uni-map-tencent-polyline-DCPolylineModel.swift
uni-map-tencent-TencentMapImpl.swift
QMapFoundationKit.framework
QMapKit.framework
QMapSDKUtils.framework
QMapVisualPlugin.framework
sqlite3
c++
uni-chooseLocation uni-chooseLocation-index.swift
uni-shareWithSystem uni-shareWithSystem-index.swift
uni-createInnerAudioContext uni-createInnerAudioContext-index.swift
uni-createInnerAudioContext-UniAudioPlayer.swift
MediaPlayer.framework
uni-getBackgroundAudioManager uni-getBackgroundAudioManager-index.swift MediaPlayer.framework

# 配置uts-config.json(可选)

DCloudUTSExtAPI工程中新建 uts-config.json 文件, uni-video模块需要添加如下配置

{
	"components": [{
		"name": "video",
		"class": "UTSSDKModulesDCloudUniVideoVideoComponent",
		"delegateClass": "VideoComponentRegister"
	}]
}

uni-push模块需要添加如下配置

{
	"hooksClasses": [
		"UTSSDKModulesDCloudUniPushHookProxy"
	]
}

uni-payment-alipay模块需要添加如下配置

{
	"hooksClasses": [
		"UTSSDKModulesDCloudUniPaymentAlipayAlipayHookProxy"
	],
	"providers": [{
		"name": "alipay",
		"service": "payment",
		"class": "UTSSDKModulesDCloudUniPaymentAlipayUniPaymentAlipayProvider"
	}]
}

uni-payment-wxpay模块需要添加如下配置

{
	"hooksClasses": [
		"UTSSDKModulesDCloudUniPaymentWxpayWxpayHookProxy"
	],
	"providers": [{
		"name": "wxpay",
		"service": "payment",
		"class": "UTSSDKModulesDCloudUniPaymentWxpayUniPaymentWxpayProvider"
	}]
}

uni-getLocation-systemy模块需要添加如下配置

{
  "providers": [{
  	"name":"system",
  	"service":"location",
  	"class":"UTSSDKModulesDCloudUniGetLocationSystemUniLocationSystemProviderImpl"
  }]
}

uni-getLocation-tencent模块需要添加如下配置

{
  "providers": [{
  	"name":"tencent",
  	"service":"location",
  	"class":"UTSSDKModulesDCloudUniGetLocationTencentUniLocationTencentProviderImpl"
  }]
}

uni-map-tencent模块需要添加如下配置

{
  "components": [{
  	"name": "map",
  	"class": "UTSSDKModulesDCloudUniMapMapComponent",
  	"delegateClass": "UniMapComponentRegister"
  }]
}

uts-config.json配置示例图

# 隐私清单

新建隐私清单:Command + N选择App Privacy点击Next,文件名称必须为PrivacyInfo

集成uni-media模块需要填写如下隐私清单

集成uni-payment-wxpay模块需要填写如下隐私清单

# 编译导出DCloudUTSExtAPI.xcframework

选择构建目标(Any iOS Device/Any iOS Simulator Device),在菜单栏中,选择Product -> Build(或使用快捷键Command + B),分别编译出真机以及模拟器的Framework文件。 在菜单栏中,选择Product -> Show Build Floder in Finder 获取编译产物所在路径。 使用xcodebuild命令行创建xcframework

xcodebuild -create-xcframework -framework 真机路径/DCloudUTSExtAPI.framework -framework 模拟器路径/DCloudUTSExtAPI.framework -output 导出路径/DCloudUTSExtAPI.xcframework

导出成功后,将 DCloudUTSExtAPI.xcframework 添加到主工程,并设置为 Embed && Sign

Apple芯片的设备编译模拟器需要在菜单栏中点击 Product -> Destination -> Show All Run Destinations ,然后选择 Rosetta模拟器 编译

# 主工程配置

根据资源文件中的manifest.json文件包含的模块名称,根据下述相关模块文档向主工程添加依赖以及工程配置

# uni-prompt

# 添加依赖库以及资源文件

资源文件
uni-prompt.bundle

# uni-canvas

# 添加依赖库以及资源文件

依赖库
DCloudUniCanvas.xcframework(Embed & Sign)

# uni-media

# 添加依赖库以及资源文件

依赖库 资源文件
DCloudPermissionAlbum.xcframework
DCloudPermissionCamera.xcframework
DCloudPermissionMicrophone.xcframework
DCMediaEditingController.bundle
DCTZImagePickerController.bundle

# Info.plist

添加相机权限描述(NSCameraUsageDescription)麦克风权限描述(NSMicrophoneUsageDescription)相册读写权限描述(NSPhotoLibraryUsageDescription)相册写权限描述(NSPhotoLibraryAddUsageDescription)

<dict>
	<key>NSCameraUsageDescription</key>
	<string>需要您的同意,才能使用摄像头,以便于相机拍摄</string>
	<key>NSMicrophoneUsageDescription</key>
	<string>需要您的同意,才能使用麦克风,以便于录制音频</string>
	<key>NSPhotoLibraryUsageDescription</key>
	<string>需要您的同意,才能访问相册,以便于图像选取</string>
	<key>NSPhotoLibraryAddUsageDescription</key>
	<string>需要您的同意,才能访问相册,以便于保存图像</string>
</dict>

# uni-getLocation-system

# 添加依赖库以及资源文件

依赖库
DCloudPermissionLocation.xcframework

# Info.plist

添加仅运行期间使用定位权限描述(NSLocationWhenInUseUsageDescription)始终使用定位权限描述(NSLocationAlwaysAndWhenInUseUsageDescription)使用临时位置权限描述(NSLocationTemporaryUsageDescriptionDictionary)

	<dict>
		<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
		<string>需要您的同意,才能访问位置信息</string>
		<key>NSLocationWhenInUseUsageDescription</key>
		<string>需要您的同意,才能在仅运行期间获取位置信息</string>
		<key>NSLocationTemporaryUsageDescriptionDictionary</key>
		<dict>
			<key>YourPurposeKey</key>
			<string>这里需要您临时授权高精度定位权限,一次临时授权时效仅app一个周期内, 每次硬启动都需要临时授权</string>
		</dict>
	</dict>

# uni-getLocation-tencent

# 添加依赖库以及资源文件

依赖库
DCloudPermissionLocation.xcframework

# Info.plist

  1. 添加仅运行期间使用定位权限描述(NSLocationWhenInUseUsageDescription)始终使用定位权限描述(NSLocationAlwaysAndWhenInUseUsageDescription)使用临时位置权限描述(NSLocationTemporaryUsageDescriptionDictionary)

    	<dict>
    		<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
    		<string>需要您的同意,才能访问位置信息</string>
    		<key>NSLocationWhenInUseUsageDescription</key>
    		<string>需要您的同意,才能在仅运行期间获取位置信息</string>
    		<key>NSLocationTemporaryUsageDescriptionDictionary</key>
    		<dict>
    			<key>YourPurposeKey</key>
    			<string>这里需要您临时授权高精度定位权限,一次临时授权时效仅app一个周期内, 每次硬启动都需要临时授权</string>
    		</dict>
    	</dict>
    

  2. 添加 TencentLBSAPIKey 配置项

    <key>TencentLBSAPIKey</key>
    <string>此处填写腾讯定位的ApiKey</string>
    

# uni-map-tencent

# 添加依赖库以及资源文件

依赖库 资源文件
DCloudPermissionLocation.xcframework uni-map-tencent.bundle

# Info.plist

  1. 添加仅运行期间使用定位权限描述(NSLocationWhenInUseUsageDescription)
    	<dict>
    		<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
    		<string>需要您的同意,才能访问位置信息</string>
    	</dict>
    
  2. 添加 TencentLBSAPIKey 配置项
    <key>TencentLBSAPIKey</key>
    <string>此处填写腾讯地图的ApiKey</string>
    

# uni-payment-alipay

# 添加依赖库以及资源文件

资源文件
AlipaySDK.bundle

# Info.plist

  1. 添加 白名单(LSApplicationQueriesSchemes)

    <key>LSApplicationQueriesSchemes</key>
    <array>
    	<string>safepay</string>
    	<string>alipay</string>
    </array>
    

  2. 添加 URLSchemes(CFBundleURLTypes)$appid_md5建议使用alipayappid的md5值

    <key>CFBundleURLTypes</key>
    <array>
    	<dict>
    		<key>CFBundleTypeRole</key>
    		<string>Editor</string>
    		<key>CFBundleURLName</key>
    		<string>Alipay</string>
    		<key>CFBundleURLSchemes</key>
    		<array>
    			<string>alipay$appid_md5</string>
    		</array>
    	</dict>
    </array>
    

  3. 添加 Alipay 配置项

    <key>Alipay</key>
    <dict>
    	<key>universalLink</key>
    	<string>此处填写通用链接</string>
    </dict>
    

# Capability

Target -> Signing & Capabilities 点击 左上角+ Capability 添加Associated Domains,将配置了 Universal Links 的域名加到 Domains 配置中

# uni-payment-wxpay

# Info.plist

  1. 添加 白名单(LSApplicationQueriesSchemes)

    <key>LSApplicationQueriesSchemes</key>
    <array>
    	<string>weixin</string>
    	<string>weixinULAPI</string>
    	<string>weixinURLParamsAPI</string>
    </array>
    

  2. 添加 URLSchemes(CFBundleURLTypes)

    <key>CFBundleURLTypes</key>
    <array>
    	<dict>
    		<key>CFBundleTypeRole</key>
    		<string>Editor</string>
    		<key>CFBundleURLName</key>
    		<string>WeChat</string>
    		<key>CFBundleURLSchemes</key>
    		<array>
    			<string>微信的appid</string>
    		</array>
    	</dict>
    </array>
    

  3. 添加 WeChat 配置项

    <key>WeChat</key>
    <dict>
    	<key>appid</key>
    	<string>此处填写微信的appid</string>
    	<key>universalLink</key>
    	<string>此处填写微信开放平台注册的通用链接</string>
    </dict>
    

# Capability

Target -> Signing & Capabilities 点击 左上角+ Capability 添加Associated Domains,将配置了 Universal Links 的域名加到 Domains 配置中

# uni-push

# 添加依赖库以及资源文件

依赖库
DCloudPermissionPush.xcframework

# Info.plist

  1. 添加通知权限描述(NSUserNotificationsUsageDescription)

  2. 添加 getui 配置项

    <key>getui</key>
    <dict>
    	<key>appid</key>
    	<string>此处填写getui的appid</string>
    	<key>appKey</key>
    	<string>此处填写getui的appKey</string>
    	<key>appSecret</key>
    	<string>此处填写getui的appSecret</string>
    </dict>

# Capability

Target -> Signing & Capabilities 点击 左上角+ Capability , 分别添加Access Wi-Fi InformationPush NotificationsTime Sensitive Notifications

# uni-verify

# Info.plist

  1. 添加 geyan 配置项
    <key>geyan</key>
    <dict>
    	<key>appid</key>
    	<string>此处填写geyan的appid</string>
    </dict>

# uni-facialRecognitionVerify

# 添加依赖库以及资源文件

依赖库 资源文件
DCloudPermissionCamera.xcframework APBToygerFacade.bundle
BioAuthEngine.bundle
ToygerNative.bundle

# Info.plist

添加相机权限描述(NSCameraUsageDescription)

<dict>
	<key>NSCameraUsageDescription</key>
	<string>需要您的同意,才能使用摄像头,以便于相机拍摄</string>
</dict>

# uni-ad

# 基础广告(必须)

# 添加依赖库以及资源文件

依赖库 资源文件
DCUniAdFoundation.xcframework(Embed & Sign) DCUniAdSDK.bundle

# Info.plist

进入uni-ad后台,复制首页中的联盟ID,将其添加到uniapp-x 节点下的 unionid 字段中

<key>uniapp-x</key>
<dict>
	<key>unionid</key>
	<string>广告联盟id,如未开通uniad可不填</string>
</dict>

# 增强广告-国内(可选)

# 添加依赖库以及资源文件

广告渠道 依赖库 资源文件 系统库
优量汇 DCUniAdGdt.xcframework
libGDTMobSDK.a
DCloudPermissionIDFA.xcframework
AppTrackingTransparency
AdSupport
CoreLocation
QuartzCore
SystemConfiguration
CoreTelephony
Security
StoreKit
AVFoundation
WebKit
JavaScriptCore
z
xml2
sqlite3
c++
Gromore DCUniAdGm.xcframework
CSJMediation.xcframework
BUAdSDK.xcframework
DCloudPermissionIDFA.xcframework
CSJAdSDK.bundle AppTrackingTransparency
Accelerate
AdSupport
AudioToolbox
AVFoundation
CoreGraphics
CoreImage
CoreLocation
CoreMotion
CoreMedia
CoreTelephony
CoreText
ImageIO
JavaScriptCore
MapKit
MediaPlayer
MobileCoreServices
QuartzCore
SystemConfiguration
Security
StoreKit
WebKit
DeviceCheck
z
xml2
sqlite3
c++
bz2
iconv
resolv.9
c++abi
快手 DCUniAdKs.xcframework
DCloudPermissionIDFA.xcframework
KSAdSDK.xcframework(Embed & Sign)
AppTrackingTransparency
AdSupport
MobileCoreServices
CoreGraphics
CoreData
CoreLocation
MediaPlayer
CoreMedia
WebKit
Accelerate
AVKit
MessageUI
QuickLook
AddressBook
CoreMotion
QuartzCore
SystemConfiguration
CoreTelephony
Security
StoreKit
AVFoundation
WebKit
z
resolv.9
sqlite3
c++
c++abi
百度 DCUniAdBd.xcframework
DCloudPermissionIDFA.xcframework
BaiduMobAdSDK.framework
baidumobadsdk.bundle AppTrackingTransparency
AdSupport
StoreKit
SafariServices
MessageUI
CoreMedia
CoreMotion
SystemConfiguration
CoreLocation
CoreTelephony
AVFoundation
Webkit
c++
Sigmob DCUniAdSgm.xcframework
DCloudPermissionIDFA.xcframework
WindSDK.xcframework
WindFoundation.xcframework
AppTrackingTransparency
AdSupport
StoreKit
CFNetwork
CoreMedia
CoreGraphics
AVFoundation
CoreLocation
CoreTelephony
SafariServices
MobileCoreServices
WebKit
SystemConfiguration
ImageIO
z
sqlite3
章鱼 OctUniAdSDK.xcframework
DCloudPermissionIDFA.xcframework
OctCore.xcframework
OctAdSDK.xcframework
OctAdSDK.bundle
OctCore.bundle
AppTrackingTransparency
AdSupport
c++

# 增强广告-国际(可选)

# 添加依赖库以及资源文件

广告渠道 依赖库 资源文件 系统库
Google AdMob DCUniAdGg.xcframework
DCloudPermissionIDFA.xcframework
UserMessagingPlatform.xcframework
Pangle PangleAdapter.xcframework
DCloudPermissionIDFA.xcframework
BURelyFoundation_Global.xcframework.xcframework
PAGAdSDK.xcframework
PAGAdSDK.bundle StoreKit
MobileCoreServices
WebKit
MediaPlayer
CoreMedia
CoreLocation
AVFoundation
CoreTelephony
SystemConfiguration
AdSupport
CoreMotion
JavaScriptCore
DeviceCheck
resolv.9
c++
libc++abi
z
sqlite3
InMobi InMobiSDK.xcframework
DCloudPermissionIDFA.xcframework
InMobiAdapter.xcframework
sqlite3.0
z
WebKit
IronSource IronSource.xcframework
DCloudPermissionIDFA.xcframework
IronSourceAdapter.xcframework
Liftoff VungleAdsSDK.xcframework
DCloudPermissionIDFA.xcframework
LiftoffMonetizeAdapter.xcframework
AdSupport
AudioToolbox
AVFoundation
CFNetwork
CoreGraphics
CoreMedia
MediaPlayer
QuartzCore
StoreKit
SystemConfiguration
z
Mintegral MintegralAdapter.xcframework
DCloudPermissionIDFA.xcframework
MTGSDK.xcframework
MTGSDKBanner.xcframework
MTGSDKBidding.xcframework
MTGSDKInterstitialVideo.xcframework
MTGSDKNativeAdvanced.xcframework
MTGSDKNewInterstitial.xcframework
MTGSDKReward.xcframework
MTGSDKSplash.xcframework
UnityAds UnityAds.xcframework
DCloudPermissionIDFA.xcframework
UnityAdapter.xcframework

集成Pangle、InMobi、IronSource、Liftoff、Mingetral、UnityAds渠道必须集成Google AdMob 国际广告需要在uni-AD后台后台审核通过之后才可以集成。审核通过之后可以连续客服获取国际广告SDK及配置。

# Info.plist

添加IDFA权限描述(NSUserTrackingUsageDescription)

<dict>
	<key>NSUserTrackingUsageDescription</key>
	<string>获取标记权限向您提供更优质、安全的个性化服务及内容,未经同意我们不会用于其他目的;开启后,您也可以前往系统“设置-隐私 ”中随时关闭</string>
</dict>

开通 Google AdMob 渠道必须添加以下

<dict>
	<key>GADApplicationIdentifier</key>
	<string>填写您的Google Admob 应用ID</string>
</dict>

开通 快手、Sigmob、百度 渠道建议添加以下权限描述

    	<dict>
    		<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
    		<string>需要您的同意,才能访问位置信息</string>
    		<key>NSLocationWhenInUseUsageDescription</key>
    		<string>需要您的同意,才能在仅运行期间获取位置信息</string>
    	</dict>

# 隐私清单

开通 优量汇、Gromore 渠道需要将该渠道的隐私清单内容手动合并到主工程的隐私清单文件中,详见目录SDK/PrivacyInfo/优量汇SDK/PrivacyInfo/Gromore