请在Podfile中添加嵌入式目标的主机目标。

6

我的项目是用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)
3个回答

9

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

解决方法:

  • 打开XCode。
  • 选择您的HOST目标。
  • 打开目标的“常规”页面。
  • 在“嵌入式二进制文件”部分,确保您的EXTENSION目标存在。 enter image description here

  • 在您的Podfile中应该有:

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


在上述的一切之后,仍然出现了相同的错误;解决方法是同时遵循其他答案(Xcode目标的依赖部分没有包括扩展,但除了CocoaPods之外的所有内容都可以正常工作,即使没有该依赖)。 - Top-Master
此外,在编辑Podfile时,将扩展目标放在主应用目标中不是必需的(至少在撰写本文时,CocoaPods版本为1.7.3)。 - undefined
此外,在编辑Podfile时,将扩展目标放在主应用程序目标中不是必需的(至少在撰写本文时,CocoaPods版本为1.7.3)。 - Top-Master

4
为了禁用您构建的NSExtension的构建/运行,您应该:
  1. 在项目导航器中单击项目文件
  2. 单击包含的应用程序目标(您要运行的目标)
  3. 单击“Build Phases”选项卡
  4. 打开目标依赖项
  5. 删除扩展名(您不想运行的那个)
  6. 要重新添加它,只需在同一位置单击+号即可。
在我的情况下成功工作。

0

为了以后的参考,我想补充一个我刚刚发现的导致这个错误信息的原因:

在主目标构建阶段中,嵌入应用程序扩展部分必须位于[CP]复制Pod资源[CP]嵌入Pods框架之上。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接