当前位置:  开发笔记 > 编程语言 > 正文

Podfile中目标中的目标

如何解决《Podfile中目标中的目标》经验,为你挑选了1个好方法。

我正在尝试将Google Mobile Ads SKD安装到我的Xcode项目中。我安装了Cocoapods,然后将Podfile初始化到我的项目中:

# 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

但是,我不明白为什么我的主项目中有目标(Cubical)。我从未真正使用过CubicalTests或CubicalUITests,因为我真的不需要测试UI或任何代码片段。我正在考虑删除这两个文件夹。

我的问题是

1)从我的Xcode项目中删除Tests和UITests文件夹是否有任何缺点?如果可以,我可以直接从Podfile中删除这两个目标吗?

2)假设我要保留这两个目标。我是否必须将广告连播添加到所有三个目标?还是两个嵌套目标继承了目标“ Cubical”的任何Pod

3)我需要将Google Mobile Ads SDK添加到链接框架中吗?还是Cocoapods已经做到了?

我的最终吊舱如下所示:

# 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

Rajamohan S.. 6

问题1:

如果您不需要执行此类测试,则删除TestsCubicalUITests目标和文件夹时没有问题。

问题2

您可以将Pod与以下几个目标共享,

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自动完成。请参阅此处,您需要使用不带cocoapods的框架来链接框架。



1> Rajamohan S..:

问题1:

如果您不需要执行此类测试,则删除TestsCubicalUITests目标和文件夹时没有问题。

问题2

您可以将Pod与以下几个目标共享,

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自动完成。请参阅此处,您需要使用不带cocoapods的框架来链接框架。

推荐阅读
jerry613
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有