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
生效步骤
- 执行
pod deintegrate清理当前工程的旧CocoaPods配置 - 执行
pod install重新生成依赖配置 - 打开Xcode工程,检查
Unity-iPhonetarget的Build Phases -> Link Binary With Libraries列表,确认没有AppsFlyerFramework - 编译运行验证冲突提示消失
内容的提问来源于stack exchange,提问作者yaoxp
相关产品推荐
相关产品推荐

