Integrating pods with all targets

后端 未结 4 1112
天命终不由人
天命终不由人 2020-12-17 10:07

I have been using CocoaPods for a few weeks now with my iOS app and it works perfectly with the one target I have been testing (let\'s call it \"MainApp\"). However, I now w

相关标签:
4条回答
  • 2020-12-17 10:54

    If you have large number of targets and don't want to add new target each time, you can use this

    def common_pods
    
       pod 'TTTAttributedLabel', '~> 1.7.0'
       pod 'iRate', '~> 1.7.5'
       pod 'MBProgressHUD', '~> 0.6'
       pod 'FlurrySDK', '~> 4.2.3'
       pod 'ACSimpleKeychain', '~> 0.0.1'
       pod 'WEPopover', '~> 0.0.1'
       pod 'AFNetworking', '~> 1.3.1'
       pod 'Nimbus', '~> 1.0.0'
       pod 'QuincyKit', '~> 2.1.9'
    
    end
    
    project = Xcodeproj::Project.open “./<projectNameHere>.xcodeproj"
    
    project.targets.each do |t|
    
    target t.name do
    
        common_pods
    
    end
    
    0 讨论(0)
  • 2020-12-17 10:57

    For CocoaPods 1.0.0, recommendation from devs is using abstract_target (but not compatible with 0.39.0):

    platform :ios, '5.0'
    
    abstract_target 'defaults' do
        pod 'TTTAttributedLabel', '~> 1.7.0'
        pod 'iRate', '~> 1.7.5'
        pod 'MBProgressHUD', '~> 0.6'
        pod 'FlurrySDK', '~> 4.2.3'
        pod 'ACSimpleKeychain', '~> 0.0.1'
        pod 'WEPopover', '~> 0.0.1'
        pod 'AFNetworking', '~> 1.3.1'
        pod 'Nimbus', '~> 1.0.0'
        pod 'QuincyKit', '~> 2.1.9'
    
        target 'MyApp'
        target 'MyAppLite'
    end
    

    For CocoaPods 0.39.0 + 1.0.0 compatibility, using def works fine (but isn't recommended by devs):

    platform :ios, '5.0'
    
    def default_pods
        pod 'TTTAttributedLabel', '~> 1.7.0'
        pod 'iRate', '~> 1.7.5'
        pod 'MBProgressHUD', '~> 0.6'
        pod 'FlurrySDK', '~> 4.2.3'
        pod 'ACSimpleKeychain', '~> 0.0.1'
        pod 'WEPopover', '~> 0.0.1'
        pod 'AFNetworking', '~> 1.3.1'
        pod 'Nimbus', '~> 1.0.0'
        pod 'QuincyKit', '~> 2.1.9'
    end
    
    target 'MyApp' do
        default_pods
    end
    
    target 'MyAppLite' do
        default_pods
    end
    
    0 讨论(0)
  • 2020-12-17 11:09

    With CocoaPods 1.x

    You can use the target blocks

    platform :ios, '13.0'
    
    
    def default_pods
        pod 'TTTAttributedLabel', '~> 1.7.0'
        pod 'iRate', '~> 1.7.5'
        pod 'MBProgressHUD', '~> 0.6'
        pod 'FlurrySDK', '~> 4.2.3'
        pod 'ACSimpleKeychain', '~> 0.0.1'
        pod 'WEPopover', '~> 0.0.1'
        pod 'AFNetworking', '~> 1.3.1'
        pod 'Nimbus', '~> 1.0.0'
        pod 'QuincyKit', '~> 2.1.9'
    end
    
    target 'MyApp' do
      default_pods
    end
    
    target 'MyAppLite' do
      default_pods
    end
    

    Relevant documentation

    0 讨论(0)
  • 2020-12-17 11:10

    From the docs:

    If no explicit target is specified, then the Pods target will be linked with the first target in your project.

    You can use link_with to link with further targets.

    Also see Multiple Targets in the Cocoapods documentation if you need different dependency configurations for different targets

    0 讨论(0)
提交回复
热议问题