Xcode警告:多个目标匹配产品的隐含依赖

10

我有一个应用程序有两个版本(付费版和免费版)。我的框架之一称为AppBootstrap,它有两个子规格(FreeVersion和PaidVersion)

现在Xcode一直在发出这个讨厌的警告(我希望在我的项目中达到零个警告,所以我不想忽略它,因为那样会让人滑向悬崖 ;) )

Multiple targets match implicit dependency for product reference 'AppBootstrap.framework'. Consider adding an explicit dependency on the intended target to resolve this ambiguity. (in target 'The Flight Tracker Free' from project 'The Flight Tracker')
Target 'AppBootstrap-FreeVersion' (in project 'AppBootstrap')
Target 'AppBootstrap-PaidVersion' (in project 'AppBootstrap')

我在谷歌上搜了一下,但找不到解决方法。 我尝试过: * 将其添加到“链接二进制文件与库”构建阶段,但没有解决问题。 * 将其添加到依赖项阶段,但它们在那里不显示。 * 在“构建设置=>其他链接器标志”中将“-framework AppBootstrap”更改为“-framework AppBootstrap-FreeVersion”,但结果出现错误。

我的podfile(简化)

source 'custom-pods/link'
source 'https://cdn.cocoapods.org/'

platform :ios, '9.0'

install! 'cocoapods',
  :generate_multiple_pod_projects => true,
  :incremental_installation => true

use_frameworks!
inhibit_all_warnings!

workspace 'MyApp'

target 'MyAppFree' do
  pod 'AppBootstrap/FreeVersion'
end

target 'MyAppPaid' do    
  pod 'AppBootstrap/PaidVersion'
end

AppBootstrap Podspec

Pod::Spec.new do |s|
    s.name        = 'AppBootstrap'
    s.version     = '3.18.2'
    s.summary     = 'iOS App Bootstrap Module.'
    s.platforms   = { ios: '9.0' }
    s.swift_version = '5.0'

    s.description = <<-DESC
        Contains classes to bootstrap ios apps.
    DESC

    s.homepage = ---
    s.license  = { type: 'MIT', file: 'LICENSE' }
    s.author   = { --- }
    s.source   = { --- }

    s.frameworks = [
        'Foundation',
        'UIKit'
    ]


    s.subspec 'PaidVersion' do |sub|
        sub.dependency 'Advertisement/Core'

        sub.source_files = [
            'AppBootstrap/source/**/*.swift'
        ]

        sub.resources = [
            'AppBootstrap/support/Localization/*.lproj',
            'AppBootstrap/support/ConsentText.plist',
            'AppBootstrap/support/Images.xcassets'
        ]

        sub.pod_target_xcconfig = {
            'APPLICATION_EXTENSION_API_ONLY' => 'NO'
        }

        sub.pod_target_xcconfig = {
            'OTHER_SWIFT_FLAGS' => '-D"PAIDVERSION"'
        }
    end

    s.subspec 'FreeVersion' do |sub|
        sub.dependency 'Advertisement/Ads'

        sub.source_files = [
            'AppBootstrap/source/**/*.swift'
        ]

        sub.resources = [
            'AppBootstrap/support/Localization/*.lproj',
            'AppBootstrap/support/ConsentText.plist',
            'AppBootstrap/support/Images.xcassets',
            'AppBootstrap/support/Colors.xcassets',
            'AppBootstrap/support/Fonts/*.otf'
        ]

        sub.pod_target_xcconfig = {
            'APPLICATION_EXTENSION_API_ONLY' => 'NO'
        }

        sub.pod_target_xcconfig = {
            'OTHER_SWIFT_FLAGS' => '-D"FREEVERSION"'
        }
    end

    s.subspec 'Undefined' do |sub|
        sub.dependency 'Advertisement/Core'

        sub.source_files = [
            'AppBootstrap/source/**/*.swift'
        ]

        sub.resources = [
            'AppBootstrap/support/Localization/*.lproj',
            'AppBootstrap/support/ConsentText.plist',
            'AppBootstrap/support/Images.xcassets',
            'AppBootstrap/support/Fonts/*.otf'
        ]

        sub.pod_target_xcconfig = {
            'APPLICATION_EXTENSION_API_ONLY' => 'NO'
        }

        sub.pod_target_xcconfig = {
            'OTHER_SWIFT_FLAGS' => '-D"UNDEFINEDVERSION"'
        }
    end

    s.default_subspec = 'Undefined'
end

非常感谢您的帮助和建议 =)


你找到解决方案了吗? - Oleg_Korchickiy
暂未完成 [需要再加八个字符...] - Saren Inden
3个回答

4

这个错误只会在“产品”->“存档”中发生。

在存档之前,您可以为单个目标进行pod install。

source 'custom-pods/link'
source 'https://cdn.cocoapods.org/'

platform :ios, '9.0'

install! 'cocoapods',
  :generate_multiple_pod_projects => true,
  :incremental_installation => true

use_frameworks!
inhibit_all_warnings!

def MyAppPods (scheme)
  if scheme == 'MyAppFree'
    pod 'AppBootstrap/FreeVersion'
  end
  if scheme == 'MyAppPaid'
    pod 'AppBootstrap/PaidVersion'
  end
end

workspace 'MyApp'

scheme = ENV['scheme']
if scheme
  target scheme do
    MyAppPods scheme
  end
else
  target 'MyAppFree' do
    MyAppPods 'MyAppFree'
  end

  target 'MyAppPaid' do    
    MyAppPods 'MyAppPaid'
  end
end

scheme='MyAppFree' pod install

0

这种情况曾经发生在我身上,当我在 Podfile 中提高了 iOS 的最低版本,但忘记在 Podfile 中为框架(目标)提高版本。


0
一个简单的解决方案是不使用 subspec,而是创建两个不同的 specs。例如:
target 'MyAppFree' do
  pod 'AppBootstrapFreeVersion'
end

target 'MyAppPaid' do    
  pod 'AppBootstrapPaidVersion'
end


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接