美文网首页iOS 功能展示
一个工程多个target配置CocoaPods

一个工程多个target配置CocoaPods

作者: 星星1024 | 来源:发表于2020-07-22 14:53 被阅读0次

    方案一

    source 'https://github.com/CocoaPods/Specs.git'
    
    platform :ios, '9.0'
    
    target 'MultiTarget' do
    
     pod 'AFNetworking'
        
     pod 'Masonry'
    
    end
    
    target 'MultiTarget copy' do
      
     pod 'AFNetworking'
        
    # pod 'Masonry'
    
    end
    
    

    方案二

    • 通过abstract方式引入(推荐)
    source 'https://github.com/CocoaPods/Specs.git'
    
    platform :ios, '9.0'
    
    #虚拟target
    abstract_target 'MultiTargetTest' do
      
      pod 'AFNetworking'
      pod 'Masonry'
      
      target 'MultiTarget'
      target 'MultiTarget copy'
      
      
    end
    
    

    根据target 添加不同依赖库

    source 'https://github.com/CocoaPods/Specs.git'
    
    platform :ios, '9.0'
    
    #虚拟target
    abstract_target 'MultiTargetTest' do
      
      pod 'AFNetworking'
      
      target 'MultiTarget' do
        pod 'Masonry'
      end
      
      target 'MultiTarget copy' do
      end
      
      
    end
    
    

    方案三

    • 循环target 添加pod
    source 'https://github.com/CocoaPods/Specs.git'
    
    platform :ios, '9.0'
    
    targetArray = ['MultiTarget','MultiTarget copy']
    targetArray.each do |t|
        target t do
            pod 'Masonry'
        end
    end
    

    相关文章

      网友评论

        本文标题:一个工程多个target配置CocoaPods

        本文链接:https://www.haomeiwen.com/subject/csdzkktx.html