如何定义嵌入框架目标的主机目标? [英] How Do I Define a Host Target That Embeds a Framework Target?

查看:63
本文介绍了如何定义嵌入框架目标的主机目标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个目录中有一个现有的工作区文件,该目录的子目录包含Xcode项目文件。当我从工作区文件的目录发出 pod install命令(我的pod版本是1.2.0)时,我收到以下警告:

I have an existing workspace file in a directory whose sub-directories contain the Xcode project files. When I issue the 'pod install' command (my pod version is 1.2.0) from the workspace file's directory, I get the following warning:

[!] Podfile包含框架目标,而Podfile不包含主机目标(嵌入框架的目标)。
如果此项目用于框架开发,则可以忽略此消息。否则,在Podfile中添加一个目标,这些目标将嵌入这些框架以使此消息消失(例如,测试目标)。

一般形式我的pod文件中的文件是:

The general form of my pod file is:

workspace 'MyWorkspace'

use_frameworks!

target 'MyFramework' do

    pod 'PodA'

    project 'MyFramework/MyFramework'

end

target 'MyApplication' do

    pod 'PodA'

    project 'MyApplication/MyApplication'

end

上面的pod文件对我有用。但是请注意,我必须对框架(确实需要它)和应用程序(确实需要通过与框架的依赖关系间接地)表达PodA依赖关系。我怀疑如果只知道如何执行警告提示我的操作,那就没有必要了-即在pod文件中表达应用程序对框架的依赖性。我在CocoaPods.org上进行了谷歌搜索,实验和阅读。一切都无济于事。目标嵌入似乎用于范围Pod依赖项-内部目标继承了外部目标的Pod依赖项。我找不到嵌入框架目标的宿主目标的示例。有人可以帮忙吗?

The above pod file works for me. Note however that I am having to express the PodA dependency for both the framework (which does indeed need it) and the application (which needs it indirectly via its dependence upon the framework). I suspect that this would not be necessary if I only knew how to do what the warning is prompting me to do - i.e. express, in the pod file, the application's dependency upon the framework. I have googled, experimented, and read on CocoaPods.org. All to no avail. Target embedding seems to be used to scope pod dependencies - the inner target inherits the pod dependencies of the outer target. I cannot find an example of a host target which embeds a framework target. Can anyone help?

推荐答案

可可豆抱怨豆荚文件中没有使用静态库\框架的目标。

Cocoa Pods is complaining that there is no target in the pod file that using the static library \ framework in the pod file.

看看这个示例项目

tl; dr

如果是静态库,则需要转到 build阶段,然后将静态库添加为目标依赖项,还将静态库.a文件添加到链接库的二进制文件中

In case of static library you need to go to "build phases" in your 'host' project and add the static library as a "target dependency", also add the static library .a file in "link binary with libraries"

框架的过程有些混乱,所以我建议克隆示例项目并查看配置。

The process for Frameworks is a little more confusing so I suggest to clone the sample project and take a look at the configuration.

这篇关于如何定义嵌入框架目标的主机目标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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