Skip to main content

如何在unity中通过pod来配置SDK

一、在mac下配置好 cocoapods#

官网地址:https://cocoapods.org

二、在unity 项目中使用 PlayerServicesResolver#

PlayerServicesResolver 官方项目地址:https://github.com/googlesamples/unity-jar-resolver

在其项目仓库中可以方便的下载到 external-dependency-manager-latest.unitypackage。然后将其导入您的项目中。

三、通过工具自动转化配置#

由于PlayerServicesResolver中配置pod需要使用其特定的xml格式和普通的pod配置不同,所以我们这边提供了一个自动转化工具。 下载地址:https://github.com/tradplus/iOS_unity_pod_tool

如果有使用 Verve smaato Ogury 快手 百度的话 使用此工具时需要 关闭 PlayerServicesResolver 的 Always add the main target to Podfile 这个设置。

  • Assets > External Dependency Manager > iOS Resolver > Settings

  • 关闭 PlayerServicesResolver 的 Always add the main target to Podfile 这个设置。

使用方法#

  • 2.将配置添加到TPPods文件中

  • 3.将 TPPods,ParsePod.sh,TPPodSet.cs 放置在同一个目录中

  • 4.在Mac的终端中执行ParsePod.sh 这样就会自动生成并更新 TPPodsDependencies.xml 和 TPPodSet.cs的内容

  • 5.将TPPodsDependencies.xml 和 TPPodSet.cs 两个文件放置在unity项目中 Assets/ExternalDependencyManager/Editor 此文件夹下

另:如果没有使用 Verve ; smaato ; Ogury ; 快手 ; 百度 ; Fyber v8.2.0+ ; Start.io v4.9.1+ ; 也不需要使用TPPodSet.cs内其他功能的时,只需要放入TPPodsDependencies.xml 就可以了。

这样当从unity项目导出xcode项目时就可以通过pod自动加载相关SDK。

TPPodSet.cs 相关说明#

  • TPPodSet.cs 中也包括 增加Info.plist内容 及 关闭bitcode 功能,请根据实际需求使用。

  • TPPodSet.cs 会处理 三方动态库的配置问题。

特殊源的说明:

  • 快手SDK 由于是动态库无法直接配置在UnityFramework中

  • 百度 如果配置在UnityFramework 中会导致SDK无法找到百度的资源包

  • Verve smaato Ogury Amazon SDK库中有动态库无法直接配置在 UnityFramework中

  • Fyber v8.2.0+ 三方更换成动态库 无法直接配置在 UnityFramework中

  • Start.io v4.9.1 三方更换成动态库 无法直接配置在 UnityFramework中

  • Maio v2.0.0+ 三方更换成动态库 无法直接配置在 UnityFramework中

  • Tapjoy v13.3.0+ 三方更换成动态库 无法直接配置在 UnityFramework中