首页 > 解决方案 > 请将嵌入式目标的主机目标添加到 Podfile

问题描述

我的项目是 Swift 2.0。我正在尝试所有可能的方法,但没有找到任何解决方案。

我的 pod 文件

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


def available_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

def available_pods_exc
    pod 'Alamofire'
    pod 'SwiftyJSON', :git => 'https://github.com/SwiftyJSON/SwiftyJSON.git'
    pod 'ReachabilitySwift'
    pod 'Kanna', :git => 'https://github.com/tid-kijyun/Kanna.git'
    pod 'AsyncSwift' , :git => 'https://github.com/duemunk/Async.git'
end



target 'link' do
    available_pods

end

target 'ReadLaterExtension' do
    available_pods_exc
    end

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

我发现以下错误

[!] 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)

标签: iosswiftxcodecocoapods

解决方案


问题不在 podfile 中,而在项目中!

修理:

  • 转到 XCode
  • 选择您的主机目标。
  • 打开目标的“常规”页面
  • 在“嵌入式​​二进制文件”部分,确保您的 EXTENSION 目标存在。 在此处输入图像描述

  • 在您的 Podfile 中,您应该有:

    target 'HostApp' do .... target 'YourExtension' do .... end end


推荐阅读