Cocoapods: Unable to find host target(s) for Keyboard and iMessage app extension

Created on 30 Nov 2016  路  12Comments  路  Source: CocoaPods/CocoaPods

Report

What did you do?

Run pod install

What did you expect to happen?

Install all pod dependencies correctly.

What happened instead?

I got this error in console
Unable to find host target(s) for ***Keyboard, ***iMessageApp.

CocoaPods Environment

Stack

   CocoaPods : 1.1.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.1 (16B2555)
       Xcode : 8.1 (8B62)
         Git : git version 2.9.3 (Apple Git-75)
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib
Repositories : master - https://github.com/CocoaPods/Specs.git @ b4e272bd703ca26cae4ebf7547a0fb9d33580d5d

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.1.1
cocoapods-try         : 1.1.0

Podfile

platform :ios, '9.0'
project '***.xcodeproj'
use_frameworks!
inhibit_all_warnings!

def communication_pods
    pod 'Argo'
    pod 'Curry'
    pod 'Alamofire', '~> 4.0'
end

def global_pods
    communication_pods
    pod 'AlamofireImage', '~> 3.1'
end

target '***App' do
    global_pods

    target '***Tests' do
        inherit! :search_paths
        pod 'Quick'
        pod 'Nimble'
    end

    target '***UITests' do
        inherit! :search_paths
    end
end

 target '***Keyboard' do
     global_pods
 end

 target '***iMessageApp' do
     global_pods
 end

post_install do |installer|
    # NOTE: If you are using a CocoaPods version prior to 0.38, replace `pods_project` with `project` on the below line
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['SWIFT_VERSION'] = '3.0'
        end
    end
end
awaiting input

Most helpful comment

Oh I noticed that the Target Dependencies field was empty. Adding the two extensions target fixed the issue. Thanks

All 12 comments

Hi! Could you post a screenshot (or just a text list) of what shows up in the list in the "Target Dependencies" build phases for your *App?

Oh I noticed that the Target Dependencies field was empty. Adding the two extensions target fixed the issue. Thanks

Awesome! Glad you got it fixed, and we appreciate you posting the solution!

BTW, if you want to make your Podfile a bit simpler, you could do:

[...]

abstract_target "App Pods" do
    target '***App'
    target '***Keyboard'
    target '***iMessageApp'

    pod 'Argo'
    pod 'Curry'
    pod 'Alamofire', '~> 4.0'

    abstract_target 'Test Pods' do
        inherit! :search_paths
        target '***Tests'
        target '***UITests'
        pod 'Quick'
        pod 'Nimble'
    end
end

[...]    

HI @orta, thanks for the tip.
In this case, how to add a pod to the main app target only? I know this syntax results more concise, but for any customization I have to extract the target from the abstract one. Probably I'll prefer to stay with the old and not-pretty Podfile version. Just for my personal curiosity, will a solution like the one below work?

abstract_target "Generic Pods" do
    target '***Keyboard'
    target '***iMessageApp'

    pod 'Argo'
    pod 'Curry'
    pod 'Alamofire', '~> 4.0'
    pod 'AlamofireImage', '~> 3.1'

    abstract_target 'Main App Pods' do
        inherit! :search_paths
        target '***App'
        pod 'FBSDKLoginKit'
        pod 'FBSDKCoreKit'
        pod 'FBSDKShareKit'
    end

    abstract_target 'Test Pods' do
        inherit! :search_paths
        target '***Tests'
        target '***UITests'
        pod 'Quick'
        pod 'Nimble'
    end
end

Hrm, I think if you remove the inherit! :search_paths from Main App Pods then it should be 馃憤

After using the new Podfile version, I got an error

framework not found Pods_***_iMessageApp

while archiving (debug was fine).
Under linked libraries settings, each target is linked to Pods_TARGETNAME.framework and the Pods_Generic_Pods_targetname.framework too. Is it right?

The Podfile I'm using is exactly the same I posted before, without the inherit! :search_paths line as @orta said

PS: the pod install operation removed also all my schemes

Seems like pod deintegrate and pod install fixed it. As I said, the target was still linked to the old .framework

Again me, just FYI, after user that Podfile, the test targets weren't compiling. Of course I forgot to move the test abstract target inside the Main App abstract target.

This is my pod file

# Uncomment this line to define a global platform for your project
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, :deployment_target => '9.0'
# ignore all warnings from all pods
inhibit_all_warnings!
use_frameworks!

def all_pods
    pod 'IQKeyboardManager'
    pod 'Instabug'
    pod "TSMessages"
    pod 'AsyncSwift' , :git => 'https://github.com/duemunk/Async.git'

    pod 'Onboard' # not used
    pod 'DZNEmptyDataSet' # not used
    pod 'iOS-Slide-Menu'
    pod 'Kanna', :git => 'https://github.com/tid-kijyun/Kanna.git'
    pod 'HanekeSwift', :git => 'https://github.com/Haneke/HanekeSwift.git'
    pod 'Alamofire'
    pod 'ObjectMapper', :git => 'https://github.com/Hearst-DD/ObjectMapper.git'
    pod 'SwiftyJSON', :git => 'https://github.com/SwiftyJSON/SwiftyJSON.git'
    pod 'ReachabilitySwift'
    pod 'SCLAlertView'
    pod 'ImageLoader'
    pod 'NVActivityIndicatorView', :git => 'https://github.com/ninjaprox/NVActivityIndicatorView.git'
    pod 'ActiveLabel'
    pod 'MWFeedParser'
    pod "SwiftElegantDropdownMenu"
    pod 'SwiftHEXColors'
    pod 'UITextView+Placeholder'
    #pod "AFDateHelper"
    pod 'DateTools'
    pod "SwiftDate", "~> 2.0"
    pod 'APAddressBook/Swift'
    pod 'FBSDKLoginKit'
    pod 'FBSDKCoreKit'
    pod 'FBSDKShareKit'
    pod 'PusherSwift', git: 'https://github.com/pusher/pusher-websocket-swift.git', branch: 'push-notifications'


end

target 'link' do
    all_pods
    end

target 'ReadLaterExtension' do

all_pods

    end

target 'Link Tests' do
    pod 'Quick', '0.3.1'
    pod 'Nimble'
end

post_install do |installer|
    # NOTE: If you are using a CocoaPods version prior to 0.38, replace `pods_project` with `project` on the below line
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['SWIFT_VERSION'] = '3.0'
        end
    end
end

error is
Unable to find host target(s) for ReadLaterExtension. 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)

pls help me to solve this

thank you

In order to disable building/running the NSExtension you build, you should:

  1. Click the project file in the project navigator
  2. Click the containing app target (the one you DO want to run)
  3. Click Build Phases tab
  4. Open Target Dependencies
  5. Remove the extension (the one you DON'T want to run)
  6. To bring it back, simply click the + sign in the same place and
    re-add it.

In my case working sucessfully

  1. Remove the extension (the one you DON'T want to run)
    > In my case working sucessfully

In my case I just add extension that was in error string. That fix issue. Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pronebird picture pronebird  路  3Comments

steffendsommer picture steffendsommer  路  3Comments

marzapower picture marzapower  路  3Comments

hmistry picture hmistry  路  3Comments

lzwjava picture lzwjava  路  3Comments