Search code examples
iosxcodeunity-game-enginecocoapods

Linked the third-party static library twice when use UnityFramework


  • unity 2019.4
  • Cocoapods 1.10.1
  • xcode 12.5

Podfile:

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

platform :ios, '10.0'

target 'UnityFramework' do
  pod 'AppsFlyerFramework', '~> 6.2.4'
end

target 'Unity-iPhone' do
end

run log

objc[5990]: Class AppsFlyerProxyManager is implemented in both /private/var/containers/Bundle/Application/97237BCE-C78A-4C22-8DE2-19D7CC866571/dev.app/dev (0x102d6b4c0) and /private/var/containers/Bundle/Application/97237BCE-C78A-4C22-8DE2-19D7CC866571/dev.app/Frameworks/UnityFramework.framework/UnityFramework (0x10c670350). One of the two will be used. Which one is undefined.
objc[5990]: Class AppsFlyerCrossPromotionHelper is implemented in both /private/var/containers/Bundle/Application/97237BCE-C78A-4C22-8DE2-19D7CC866571/dev.app/dev (0x102d6b510) and /private/var/containers/Bundle/Application/97237BCE-C78A-4C22-8DE2-19D7CC866571/dev.app/Frameworks/UnityFramework.framework/UnityFramework (0x10c6703a0). One of the two will be used. Which one is undefined.

AppsFlyerFramework is static library

$ file Versions/A/AppsFlyerLib
Versions/A/AppsFlyerLib: Mach-O universal binary with 4 architectures: [i386:current ar archive] [arm_v7] [x86_64] [arm64]
Versions/A/AppsFlyerLib (for architecture i386):    current ar archive
Versions/A/AppsFlyerLib (for architecture armv7):   current ar archive
Versions/A/AppsFlyerLib (for architecture x86_64):  current ar archive
Versions/A/AppsFlyerLib (for architecture arm64):   current ar archive

I tried to solve this problem:modify the Podfile as follows:

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

platform :ios, '10.0'

target 'UnityFramework' do
  pod 'AppsFlyerFramework', '~> 6.2.4'
end

target 'Unity-iPhone' do
end

static_frameworks = ['AppsFlyerFramework']
# make all the static frameworks into static frameworks by overriding the static_framework? function to return true
pre_install do |installer|
  installer.pod_targets.each do |pod|
    puts pod.name
    if static_frameworks.include?(pod.name)
      puts "Overriding the static_framework? method for #{pod.name}"
      def pod.static_framework?;
        true
      end
    end
  end
end

But it didn't solve the problem

UnityFramework is dynamic library。Unity-iPhone depends on UnityFramework. UnityFramework depends on third-party framework

UnityFramework already linked the third-party static library.How to prevent Unity-iPhone to link the third-part static library.

My English is not good, if there is a description is not clear, I will add


Solution

  • I also encountered the same problem.

    1. UnityFramework is a dynamic framework, It Must link dependent 3Party libraries If you declare and use them in source codes.
    2. You must make sure Unity-iPhone didn't link the same framework as UnityFramework.

    If there are any other solutions, notify me.