Cocoapods: "Unable to find host target(s)" with static library target

Created on 21 Apr 2017  路  11Comments  路  Source: CocoaPods/CocoaPods

What did you do?

Run pod install to install dependencies on a project StaticLib containing a single Cocoa Touch Static Library target.

What did you expect to happen?

Install all pod dependencies correctly.
Note that if I had a project containing a single Cocoa Touch Dynamic Framework target, pod install would just log a warning about missing host target instead of failing.
I think that the same should happen for static library targets.

What happened instead?

Installation fails with the following error message:

[!] Unable to find host target(s) for StaticLib. Please add the host targets for the embedded targets to the Podfile.
Certain kinds of targets require a host target. A host target is a "parent" target which embeds a "child" target. These are example types of targets that need a host target:
- Framework
- App Extension
- Watch OS 1 Extension
- Messages Extension (except when used with a Messages Application)

CocoaPods Environment

Stack

   CocoaPods : 1.2.1
        Ruby : ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]
    RubyGems : 2.0.14.1
        Host : Mac OS X 10.12.4 (16E195)
       Xcode : 8.3.1 (8E1000a)
         Git : git version 2.11.0 (Apple Git-81)
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib
               master - https://github.com/CocoaPods/Specs.git @ a91d4fe9993eea485f42845382746218dcaf38a9

Installation Source

Executable Path: /usr/local/bin/pod

Plugins

cocoapods-art          : 1.0.0
cocoapods-deintegrate  : 1.0.1
cocoapods-dependencies : 1.0.0
cocoapods-plugins      : 1.0.0
cocoapods-search       : 1.0.0
cocoapods-stats        : 1.0.0
cocoapods-trunk        : 1.2.0
cocoapods-try          : 1.1.0
slather                : 2.3.0

Podfile

platform :ios, 10

target 'StaticLib'
pod 'AFNetworking'
project 'StaticLib/StaticLib.xcodeproj'

Project that demonstrates the issue

See project at https://bitbucket.org/mirkoluchi/cocoapods-issues (folder issue-6673)

confirmed defect

Most helpful comment

Encountered the same issue here, it seems that it happens in version 1.2.x only, I've used the following command to resolve it temporarily.

pod _1.1.1_ install

It didn't happen for me in version 1.1.1.

All 11 comments

Having this same issue using CocoaPods v1.2.1. Temporary fix for me was downgrading to v1.0.1.

Erg. Yep I think I forgot one piece of the static lib puzzle when I was working on support for this. Will fix. I was recently on vacation, so I'm still catching up on issues and things while I was out. I'll try to get a fix up shortly (next week or so). Thanks for the report!

Posting this here since I'd rather not create another issue & I believe this is related.
I'm currently getting this issue & had a rough time trying to figure.

Working with this example project:
https://github.com/benasher44/CocoaPodsLibExample

To reproduce, remove the subproject "SampleStaticLib.xcodeproj" from the "SampleApp" project whilst maintaining it added within the workspace:

screen capture on 2017-04-27 at 16-04-46

Then run pod install. The output will be as follows:

[!] Unable to find host target(s) for SampleStaticLib. Please add the host targets for the embedded targets to the Podfile.
Certain kinds of targets require a host target. A host target is a "parent" target which embeds a "child" target. These are example types of targets that need a host target:
- Framework
- App Extension
- Watch OS 1 Extension
- Messages Extension (except when used with a Messages Application)

Which does not provide an adequate explanation as to what's wrong.


I might add that prior to 1.2.1 I was able to install pods against both targets fine without having to add the project as subproject within "SampleApp" and to Target Dependencies.

Encountered the same issue here, it seems that it happens in version 1.2.x only, I've used the following command to resolve it temporarily.

pod _1.1.1_ install

It didn't happen for me in version 1.1.1.

Same here, static lib target/project in a workspace that also contains a framework target (uses same source files but not cocoapods). Downgrading to 1.2.0 fixed the issue so bug is in 1.2.1 not 1.2.x as mentioned earlier.

Fix is up. I'd appreciate if someone could verify the fix here: #6721. Thanks!

The fix is now on CocoaPods master and should be available in the next release. I'd appreciate though if someone could try using CocoaPods master and give a 馃憤 :)

What's is the solution to make it work with CocoaPods 1.2.1. I have another Pod dependency to React that requires 1.2.0 at least.

I tested the fix but, unless I didn't correctly install the gem from the master branch, the fix is not working.

I did this:

  • cloned https://github.com/CocoaPods/CocoaPods
  • changed lib/cocoapods/gem_version.rb so that version is 1.2.2
    VERSION = '1.2.2'.freeze unless defined? Pod::VERSION
  • changed cocoapods.gemspec hardcoding dependency from cocoapods-core 1.2.1
    s.add_runtime_dependency 'cocoapods-core', "= 1.2.1"
  • built the gemspec
    gem build cocoapods.gemspec
  • installed the built gemspec
    sudo gem install cocoapods-1.2.2.gem

Launching聽pod install on the sample project at https://bitbucket.org/mirkoluchi/cocoapods-issues (folder issue-6673) gives the the same error for which this issue was opened:

[!] Unable to find host target(s) for StaticLib. Please add the host targets for the embedded targets to the Podfile.
Certain kinds of targets require a host target. A host target is a "parent" target which embeds a "child" target. These are example types of targets that need a host target:
- Framework
- App Extension
- Watch OS 1 Extension
- Messages Extension (except when used with a Messages Application)

Here my environment:

### Stack

CocoaPods : 1.2.2
Ruby : ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]
RubyGems : 2.0.14.1
Host : Mac OS X 10.12.5 (16F73)
Xcode : 8.3.2 (8E2002)
Git : git version 2.11.0 (Apple Git-81)
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib
Repositories :
master - https://github.com/CocoaPods/Specs.git @ c28100e5298731e0aa8bf93dd4f0d06bc428b454

### Installation Source

Executable Path: /usr/local/bin/pod

### Plugins

cocoapods-deintegrate : 1.0.1
cocoapods-plugins : 1.0.0
cocoapods-search : 1.0.0
cocoapods-stats : 1.0.0
cocoapods-trunk : 1.2.0
cocoapods-try : 1.1.0
slather : 2.3.0

### Podfile

```ruby
platform :ios, 10

target 'StaticLib'
pod 'AFNetworking'
project 'StaticLib/StaticLib.xcodeproj'

```

Can confirm 1.3.0.beta.1 has fixed this for me.

sudo gem install -n /usr/local/bin cocoapods --pre

update cocoapods version over 1.2.1! has fixed this problem.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

steffendsommer picture steffendsommer  路  3Comments

spencerkohan picture spencerkohan  路  3Comments

dawnnnnn picture dawnnnnn  路  3Comments

hmistry picture hmistry  路  3Comments

iosdev-republicofapps picture iosdev-republicofapps  路  3Comments