> For the complete documentation index, see [llms.txt](https://platform-business.gitbook.io/adx/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://platform-business.gitbook.io/adx/zh/ios/integrate.md). Agents can also search and read this documentation through its [MCP server](https://platform-business.gitbook.io/adx/~gitbook/mcp).

# Integrate

## 0. 最新 ADX iOS SDK 版本

{% hint style="success" %}
Version 2.9.2

Release Date : 2026/11/18
{% endhint %}

## 1. 最低支持规格

{% hint style="info" %}

* iOS 15.0 或更高版本
* Xcode 26.2 或更高版本
  {% endhint %}

{% hint style="danger" %}
从 ADX iOS SDK 2.7.1 版本开始，如果 iOS 应用项目的 info.plist 文件中包含 "AppLovinSdkKey" 键，应用启动后将会在 Xcode 控制台输出以下错误信息并导致异常终止，因此需要将其移除。\
\
\[AppLovinSdk] ERROR \[ALSdk] Invalid initialization process: please remove the AppLovinSdkKey entry from your Info.plist and set your SDK key with the ALSdkInitializationConfiguration object. Then initialize the SDK as soon as possible with -\[ALSdk initializeWithConfiguration:completionHandler:] before accessing any SDK fields or APIs.
{% endhint %}

## 2. 添加 ADX iOS SDK <a href="#adxlibrary-cocoapods" id="adxlibrary-cocoapods"></a>

{% hint style="info" %}
根据 ADX iOS SDK 更新，以下内容可能会发生变化。
{% endhint %}

### Swift Package Manager&#x20;

1. 在 Xcode 中打开您的项目
2. 依次选择 File > Add Package Dependencies...
3. 输入包仓库 URL：<https://github.com/adxcorp/ADXLibrary\\_iOS\\_Release.git>
4. 选择版本规则（例如从 2.9.2 开始选择 "Up to Next Major Version"）
5. 点击 Add Package
6. 选择 ADXLibrary 并将其添加到您的 target 中。其余的产品均为可选项——仅添加您项目所需要的产品。

{% hint style="info" %}
请勿选择 ADXLibrary-KADP。
{% endhint %}

7. 在 Xcode 中启用 -`ObjC` 标志：点击项目设置（project settings），进入 Build Settings 选项卡，搜索 Other Linker Flags 并添加 `-ObjC`。

### Cocoapods

1\. 打开项目的 `Podfile`，并添加以下内容。

```
# 添加库下载源
source 'https://github.com/adxcorp/AdxLibrary_iOS_Release.git'
source 'https://github.com/CocoaPods/Specs.git'      

# 部署目标版本 (Deployment Target Version)
platform :ios, '15.0'

# 添加 ADX 库（横幅、原生、插屏、激励）
pod 'ADXLibrary', '2.9.2'

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      # 如果在 Xcode 27.0 及更高版本中发生与 iOS 最低部署版本相关的构建错误，请添加以下代码。
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '15.0'

      # 在 Xcode 15.0 及以上版本，如果出现与 TOOL CHAIN 相关的构建错误，请添加以下代码。
      xcconfig_path = config.base_configuration_reference.real_path
      xcconfig = File.read(xcconfig_path)
      xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")
      File.open(xcconfig_path, "w") { |file| file << xcconfig_mod }
    end
  end
end
```

{% hint style="warning" %}
ADX SDK 2.9.2 是通过 CocoaPods 发布的最后一个版本。 对于后续版本，建议使用 Swift Package Manager (SPM) 安装 SDK。
{% endhint %}

{% hint style="info" %}
在 Xcode 27.0 及更高版本中，所有 Target 的最低部署版本必须为 iOS 15.0 或更高版本。ADX SDK 2.9.0 及以下版本支持 iOS 13.0，因此在 Xcode 27 中使用 CocoaPods 时可能会导致构建失败。

在这种情况下，请参考上面的 Podfile 内容进行修改。
{% endhint %}

{% hint style="info" %}
在 Xcode 15.0 及以上版本构建时，某些广告网络 SDK 可能会出现如下错误。

在这种情况下，请参考上面的 Podfile 内容进行修改。

***

**DT\_TOOLCHAIN\_DIR cannot be used to evaluate LIBRARY\_SEARCH\_PATHS, use TOOLCHAIN\_DIR instead**
{% endhint %}

2\. 使用以下命令安装库，并找到扩展名为 `.xcworkspace` 的文件并打开。

```ruby
pod install --repo-update
```

## 3. Project Setting

1\) 在项目的 `Build Settings` 中，将 `Enable Bitcode` 修改为 No。

![](https://3685813980-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlmlH74WGKvqQtBVVPqIu%2Fuploads%2Fgit-blob-a6dfc92ae2d9ac1f9f1abb6b6d98432b5a0173b3%2F%EC%8A%A4%ED%81%AC%EB%A6%B0%EC%83%B7%202021-06-16%20%EC%98%A4%ED%9B%84%204.35.54.png?alt=media)

2\) 在 Xcode > Build Settings > Other Linker Flags 中，如果使用 "-all-load" 或 "-force\_load" 标志进行构建，可能会发生符号重复 (Symbol Duplicate)。在这种情况下请改为使用 "-ObjC" 标志。

<figure><img src="https://3685813980-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlmlH74WGKvqQtBVVPqIu%2Fuploads%2Fgit-blob-2bc7ce8782ac83115d10a6b18659198247835c29%2F%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%B5%E1%86%AB%E1%84%89%E1%85%A3%E1%86%BA%202023-02-16%20%E1%84%8B%E1%85%A9%E1%84%8C%E1%85%A5%E1%86%AB%209.55.26%20(1).png?alt=media" alt=""><figcaption></figcaption></figure>

3\) 选择构建目标后 > Build Settings > Framework Search Paths 中确认是否已添加 "**$(inherited)**" 值，如果未添加则可能出现找不到相关库的构建错误，请务必添加。

<figure><img src="https://3685813980-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlmlH74WGKvqQtBVVPqIu%2Fuploads%2Fgit-blob-f70ecb9d1d634a62f46dd5499cee853dfd5e9154%2F%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%B5%E1%86%AB%E1%84%89%E1%85%A3%E1%86%BA%202023-04-07%20%E1%84%8B%E1%85%A9%E1%84%92%E1%85%AE%206.40.56.png?alt=media" alt=""><figcaption></figcaption></figure>

## 4. iOS 14+ 支持

如果支持 iOS 14+ [ATT(App Tracking Transparency) Framework](https://developer.apple.com/documentation/apptrackingtransparency?language=objc)，则需要应用以获取 IDFA (Identifier for Advertisers) 标识符。详细方法请参考以下链接。

{% content-ref url="/pages/yYlqKdhUqV18j2Ly5nZb" %}
[App Tracking Transparency](https://platform-business.gitbook.io/adx/zh/ios/supporting-ios-14/app-tracking-transparency.md)
{% endcontent-ref %}

## 5. 设置 AdMob APP ID

* 在 `Info.plist` 文件中，添加 `GADApplicationIdentifier` 键和已发放的 AdMob APP ID。<br>

  <div data-gb-custom-block data-tag="hint" data-style="danger" class="hint hint-danger"><p>如果未添加 <code>GADApplicationIdentifier</code>，则会在 <code>Xcode</code> 控制台 中显示以下消息，并导致应用异常退出。<br><code>The Google Mobile Ads SDK was initialized incorrectly.</code></p><hr><p>&#x3C;key>GADApplicationIdentifier&#x3C;/key><br>&#x3C;string>ADMOB_APP_ID&#x3C;/string></p></div>
