Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
856 views
in Technique[技术] by (71.8m points)

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...