将pod与所有目标集成 [英] Integrating pods with all targets

查看:127
本文介绍了将pod与所有目标集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用我的iOS应用程序已经使用CocoaPods几周了,它与我测试的一个目标(我们称之为MainApp)完美配合。但是,我现在想要构建一个不同的目标(MyAppLite)并注意到构建失败(在其中一个pod的头文件中找不到文件)。



我注意到的构建设置的差异如下:




  • 其他链接器标志不包含MyAppLite中所需的框架

  • MyAppLite中的框架/标题/库搜索路径都是空的

  • MyAppLite中没有MainApp中的用户定义构建设置



如何确保在运行 pod install 时,所有目标都链接了库? / p>

作为参考,这是我的Podfile:

  platform:ios, '5.0'

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'


解决方案

使用CocoaPods 0.x



您可以使用 link_with 指令

  platform:ios,'5.0'

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'

link_withMyApp
link_withMyAppLite

这将生成 libPods.a ,它会将其链接到 Target1 Target1



相关文档



  • 注意,cocoapods会自动链接每个目标在您的项目的podfile中。因此,目标的名称应该匹配。如果出于任何原因要在podfile中使用其他名称指定目标,可以设置 link_with 属性:

      target:test,:exclusive => true 
    link_with'MyAppTests'
    end


  • 目标,按默认情况下,如果父级有不同的平台,则是独占的。


  • Podfile的主要目标始终与最终项目的第一个目标相关联。 / p>








使用CocoaPods 1.x




现在不支持Podfile中link_with的规范。


参见其他答案。


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 want to build a different target ("MyAppLite") and noticed that the build failed (file not found on one of the pods' header files).

The differences in the Build Settings I've noticed are as follows:

  • Other Linker Flags does not contain the required frameworks in MyAppLite
  • Framework/Header/Library Search Paths are all empty in MyAppLite
  • None of the User-Defined Build Settings in MainApp are present in MyAppLite

How can I ensure that when I run pod install, all targets have the libraries linked?

For reference, here is my Podfile:

platform :ios, '5.0'

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'

解决方案

With CocoaPods 0.x

You can use the link_with directive

platform :ios, '5.0'

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'

link_with "MyApp"
link_with "MyAppLite"

This will produce libPods.a and it will link it to Target1 and Target1.

Relevant documentation:

  • Note, that cocoapods automatically links every target in the podfile with your project. For this reason the names of the targets should match. If for any reason you want to specify a target in your podfile with a different name, you can set the link_with attribute:

    target :test, :exclusive => true do
        link_with 'MyAppTests'
    end
    

  • Targets, by default, are exclusive if their parent has a different platform.

  • The main target of the Podfile, is always linked with the first target of the final Project.


With CocoaPods 1.x

The specification of link_with in the Podfile is now unsupported.

See other answers.

这篇关于将pod与所有目标集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆