Search code examples
ioscocoapodspodspecpodfile

Exclude pod depends on platform in podfile


I need to exclude a pod from my podfile depends on the platform. I don't want to add another target, my podfile needs have only 1 target.

Here an example:

target 'single_target' do
    #if platform is iOS
    pod 'PodForIOS'
    #if platform is OSX
    pod 'PodForOSX'
end

My issue: How can I specify which pods belongs to which platform ?

Thanks


Solution

  • Finnaly I've found a solution

    In the podfile:

    target 'single_target' do
        pod 'PodForIOS'
        pod 'PodForOSX'
    end
    

    In the .podspec:

    # Speficy platforms
    s.platform = :ios, :osx
    s.ios.deployment_target = '6.0'
    s.osx.deployment_target = '10.8'
    
    # Set dependency
    s.ios.dependency 'PodForIOS'
    s.osx.dependency 'PodForOSX'