步骤二:集成 SDK

最近更新时间:2024-02-26 10:34:51

我的收藏

前置条件

环境要求

iOS >= 9.0
Xcode >= 10.0

组件依赖

tars
MQQTcc
MQQComponents
TMFSSL
TMFShark
TMFProfile
SSZipArchive
PromiseObjC
MJRefresh
Masonry
SocketRocket
Brotli
CocoaAsyncSocket
Lame
TMFBaseCore
TMFJSBridge
TMFUploader

集成方式

TCMPPSDK 的集成方式有以下2种,可选择其一进行集成:
CocoaPods 集成 SDK
手动集成 SDK

CocoaPods 集成 SDK

1. 在您项目中的 Podfile 文件里添加 tmf 源及小程序依赖模块:
#TCMPP Pods 仓库
source 'https://e.coding.net/tmf-work/tmf/tmf-repo.git'

target 'YourTarget' do
# ――― TCMPP -----―――――――――――――――――――――――――――――――――――――――――――――――――――――--- #
pod 'TCMPPSDK'
pod 'TCMPPExtScanCode'
pod 'TCMPPExtMedia'

end
其中,YourTarget 为您的项目需要引入 TMFApplet 的 target 的名字。
2. Terminal cd 到 Podfile 文件所在目录,并执行 pod install 进行组件安装。
$ pod install
说明:
如果报 Couldn't determine repo type for URL: 'https: //e.coding.net/tmf-work/tmf/tmf-repo.git':错误,则需要在执行pod install前执行 pod repo add specs https://e.coding.net/tmf-work/tmf/tmf-repo.git。

手动集成 SDK

1. 添加 SDK
将 TCMPPSDK 组件的目录添加到您项目的 Xcode Project 中的合适位置,并选择合适的 target。
您可以把组件的目录从 Finder 直接拖动到 Xcode Project 中,以进行快捷添加。

2. 添加依赖的 SDK
把 TCMPPSDK 依赖的所有组件添加到项目中,依赖的组件列表,请参见前置条件中的 组件依赖
3. 添加依赖的系统库
把 TCMPPSDK 依赖的系统库添加到项目中,在 Xcode 中打开 project 设置页,选中相关的 target,单击 General,在“Linked Frameworks and Libraries”中进行添加。
4. 系统库依赖如下:
Foundation.framework
CoreTelephony.framework
CFNetwork.framework
Security.framework
SystemConfiguration.framework
CoreService.framework
CoreFoundation.framework
libz.tdb
libc++.tbd
libc.tbd
libz2.tbd
libsqlite3.0.tbd
5. project 设置
添加 TCMPPSDK 后,需要进行相关的 Project 设置。在 Xcode 中打开 Project 设置页,选中相关的 target,进行以下设置:
选择 Build Settings > Linking > Other Linker Flags,增加:-ObjC
选择 Build Settings > Apple Clang - Custom Compiler Flags > Other C Flags,增加:
-fshort-wchar
-D__FIXWCHART__