You need to enable JavaScript to run this app. UnityFramework接入第三方静态库出现重复链接问题咨询
优惠活动
大模型
产品
解决方案
定价
更多

UnityFramework接入第三方静态库出现重复链接问题咨询

修复方案

问题根因

你遇到的重复链接问题是CocoaPods默认依赖继承规则导致的:主target Unity-iPhone 默认会继承所有子依赖的完整链接配置,已经被静态打包进UnityFramework的AppsFlyerFramework被二次链接到主app的二进制中,触发符号重复冲突。
你之前修改static_framework?的方案只是显式声明了该库为静态库,没有切断主target的无效链接继承,所以不生效。

最终Podfile配置

直接替换为以下配置即可:

source 'https://cdn.cocoapods.org/'
use_frameworks!

platform :ios, '10.0'

target 'UnityFramework' do
  # 显式指定该依赖为静态链接
  pod 'AppsFlyerFramework', '~> 6.2.4', :linkage => :static
end

target 'Unity-iPhone' do
  # 仅继承依赖的搜索路径,不继承链接配置,避免重复链接
  inherit! :search_paths
end

# 可选:如果上面配置生效不彻底,加这段脚本强制移除主target的链接参数
post_install do |installer|
  installer.pods_project.targets.each do |target|
    next unless target.name == 'Unity-iPhone'
    target.build_configurations.each do |config|
      config.build_settings['OTHER_LDFLAGS']&.gsub!('-framework "AppsFlyerFramework"', '')
      config.build_settings['OTHER_LDFLAGS']&.strip!
    end
  end
end

生效步骤

  1. 执行pod deintegrate清理当前工程的旧CocoaPods配置
  2. 执行pod install重新生成依赖配置
  3. 打开Xcode工程,检查Unity-iPhone target的Build Phases -> Link Binary With Libraries列表,确认没有AppsFlyerFramework
  4. 编译运行验证冲突提示消失

内容的提问来源于stack exchange,提问作者yaoxp

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.20 11:06:01