Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode warning: Multiple targets match implicit dependency for product

I have an app that comes in two flavors (paid and free). One of my frameworks is called AppBootstrap, which has two subspecs (FreeVersion and PaidVersion)

Now Xcode keeps giving this annoying warning (I aim for zero warnings in my project so I do not just want to ignore it, slippery slope and stuff like that ;) )

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')

I googled it a bit but I could not find how to solve this. I tried * adding it in the 'Link Binary With Libraries' build phase but that did not solve it. * adding it to the dependencies phase but they do not show up there. * changing the '-framework AppBootstrap' in 'Build settings => Other Linker Flags' to '-framework AppBootstrap-FreeVersion' but that just ends up in errors.

My podfile (simplified)

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

Any help/advice is greatly appreciated =)

like image 999
Saren Inden Avatar asked Oct 16 '19 06:10

Saren Inden


1 Answers

the error is just happen in Pruduct -> Archive.

you can pod install for single target before archive.

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
like image 56
Huang Qiaobo Avatar answered Jan 04 '23 06:01

Huang Qiaobo