How Do I Define a Host Target That Embeds a Framework Target?

天涯浪子 提交于 2019-12-18 07:57:08

问题


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:

[!] The Podfile contains framework targets, for which the Podfile does not contain host targets (targets which embed the framework). If this project is for doing framework development, you can ignore this message. Otherwise, add a target to the Podfile that embeds these frameworks to make this message go away (e.g. a test target).

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

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?


回答1:


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

Take a look at this sample project

tl;dr

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.



来源:https://stackoverflow.com/questions/47399558/how-do-i-define-a-host-target-that-embeds-a-framework-target

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!