Cocoapods: I can't find a way to exclude pod which doesn't support Mac Catalyst from target description in pod-file for Mac Catalyst.

Created on 23 Nov 2019  Â·  8Comments  Â·  Source: CocoaPods/CocoaPods

Report

What did you do?

I am building my app for Mac Catalyst with third-party pod which doesn't support Mac Catalyst.

What did you expect to happen?

I can't find a way to exclude pod which doesn't support Mac Catalyst from target description in pod-file for Mac Catalyst.

What happened instead?

My build failed with error about the pod which doesn't support Mac Catalyst.

CocoaPods Environment

Stack

   CocoaPods : 1.8.4
        Ruby : ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]
    RubyGems : 3.0.3
        Host : Mac OS X 10.15 (19A583)
       Xcode : 11.2 (11B52)
         Git : git version 2.11.0
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib
Repositories : master - git - https://github.com/CocoaPods/Specs.git @ c64738cb77cc7e5514f3b9fbb90534c2619e5c44
               trunk - CDN - https://cdn.cocoapods.org/

Installation Source

Executable Path: /usr/local/bin/pod

Plugins

cocoapods-deintegrate : 1.0.4
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.0
cocoapods-stats       : 1.1.0
cocoapods-trunk       : 1.4.1
cocoapods-try         : 1.1.0

Podfile

# Uncomment the next line to define a global platform for your project
platform :ios, '11.0'

def rx_base
  pod 'RxSwift',    '5.0.0'
  pod 'RxOptional', '4.0.0'
end

# ignore all warnings from all pods
inhibit_all_warnings!

target 'MyProject' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  # use_frameworks!

  # Pods for MyProject
  pod 'Fabric',                '1.10.2'
  pod 'Crashlytics',           '3.14.0'
  pod 'Firebase/Core',         '6.7.0'

  rx_base
  pod 'RxCocoa',               '5.0.0'
  pod 'RxKeyboard',            '1.0.0'
  pod 'RxDataSources',         '4.0.1'

  pod 'RxMKMapView',           '5.0.0'
  pod 'Dip',                   '7.0.1'

end

target 'MyProjectTests' do
  inherit! :search_paths
  rx_base
  pod 'RxTest', '5.0.0'
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['SWIFT_VERSION'] = '5.0'
    end
  end
end
awaiting input

Most helpful comment

Feature to include specific pods to either iOS or MacCatalyst would be really useful! Right now you have patch xcconfigs yourself 😞 There are tons of frameworks and static libraries that won't use/create xcframeworks since they support iOS only so definetely thumbs up for this feature!

If you link some library or framework in Xcode, and set it to be iOS so it won't link to Catalyst target, it adds platformFilter with either ios or maccatalyst value to the project file:

D3655E26216CDF5400B94507 /* libSomeStaticForIOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3E37E1B211C64690029E474 /* libSomeStaticForIOS.a */; platformFilter = ios; };

For linking through xcconfig files it is easy as well, you can specify:

OTHER_LDFLAGS[sdk=iphone*] = -framework "Crashlytics"
OTHER_LDFLAGS[sdk=macosx*] = -framework "SomeCatalystSpecificFramework"

Sources:
https://stackoverflow.com/questions/58635911/exclude-pod-when-porting-to-mac-with-catalyst
https://stackoverflow.com/questions/58402986/differentiate-between-ios-and-maccatalyst-in-xcconfig-file

All 8 comments

Define your targets such that targets supporting Catalyst don't depend on pods that don't support Catalyst.

In this case I should create a new target and link each file in my project with it. I think it will bring the redundant entity to the light.
Instead I would prefer to have possibly to describe independent pod sets for Catalyst and without, but on same target.
What do you think?

I'm not aware there's a way to tell Xcode to have different dependencies on the same target for Catalyst versus iOS. And if that's the case, I don't think that CocoaPods can solve this.

Is there anything further to be done here?

Nothing from my side.

Feature to include specific pods to either iOS or MacCatalyst would be really useful! Right now you have patch xcconfigs yourself 😞 There are tons of frameworks and static libraries that won't use/create xcframeworks since they support iOS only so definetely thumbs up for this feature!

If you link some library or framework in Xcode, and set it to be iOS so it won't link to Catalyst target, it adds platformFilter with either ios or maccatalyst value to the project file:

D3655E26216CDF5400B94507 /* libSomeStaticForIOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3E37E1B211C64690029E474 /* libSomeStaticForIOS.a */; platformFilter = ios; };

For linking through xcconfig files it is easy as well, you can specify:

OTHER_LDFLAGS[sdk=iphone*] = -framework "Crashlytics"
OTHER_LDFLAGS[sdk=macosx*] = -framework "SomeCatalystSpecificFramework"

Sources:
https://stackoverflow.com/questions/58635911/exclude-pod-when-porting-to-mac-with-catalyst
https://stackoverflow.com/questions/58402986/differentiate-between-ios-and-maccatalyst-in-xcconfig-file

@iKleMiX Looks like the way. Thx! I'll take a look.

This issue will be auto-closed because there hasn't been any activity for a few months. Feel free to open a new one if you still experience this problem :+1:

Was this page helpful?
0 / 5 - 0 ratings