代码之家  ›  专栏  ›  技术社区  ›  Pablo

Podfile中目标内的目标

  •  7
  • Pablo  · 技术社区  · 8 年前

    我正在尝试将谷歌移动广告SKD安装到我的Xcode项目中。我安装了Cocoapods,然后在我的项目中初始化了一个pod文件:

    # Uncomment the next line to define a global platform for your project
    platform :ios, '10.2'
    
    target 'Cubical' do
      # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
      use_frameworks!
    
      # Pods for Cubical
    
      target 'CubicalTests' do
        inherit! :search_paths
        # Pods for testing
      end
    
      target 'CubicalUITests' do
        inherit! :search_paths
        # Pods for testing
      end
    
    end
    

    我正在考虑删除这两个文件夹。

    1) 从我的Xcode项目中删除Tests和UITests文件夹有什么缺点吗?如果我这么做了,我能从我的pod文件中删除这两个目标吗?

    3) 我是否需要将谷歌移动广告SDK添加到链接框架中?还是椰子荚已经做到了?

    # Uncomment the next line to define a global platform for your project
    platform :ios, '10.2'
    
    target 'Cubical' do
      # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
      use_frameworks!
      pod 'Google-Mobile-Ads-SDK'
    
      # Pods for Cubical
    
      target 'CubicalTests' do
        inherit! :search_paths
        # Pods for testing
      end
    
      target 'CubicalUITests' do
        inherit! :search_paths
        # Pods for testing
      end
    
    end
    
    1 回复  |  直到 8 年前
        1
  •  10
  •   Rajamohan S    8 年前

    问题1:

    Tests , CubicalUITests 目标和;文件夹,如果您不需要执行此类测试。

    :

    您可以与以下几个目标共享吊舱,

    def shared
    pod 'Google-Mobile-Ads-SDK'
    end
    
    target 'Target1' do
    shared
    end
    
    target 'Terget2' do
    shared
    end
    

    针对多个目标的全球吊舱

    #Global Pod for all targets
    pod 'Google-Mobile-Ads-SDK'
    
    target 'target1' do
        pod 'Fabric' #Pod for nested Target. i.e., Google-Mobile-Ads-SDK + Fabric
    end
    
    target 'target2' do
     pod 'RadioButton'#Pod for nested Target. i.e., Google-Mobile-Ads-SDK + RadioButton
    end
    

    嵌套目标的吊舱:

    #Global Pod for all targets
    pod 'Google-Mobile-Ads-SDK'
    
    target 'target1' do
       pod 'RadioButton' #Available for target1 and target2
       target 'target2 copy' do 
          pod 'Fabric' #Available for target2 only
       end
    end
    

    问题3:

    链接的框架由cocoapods自动完成。看见 here 您需要使用没有cocoapod的框架来链接框架。