【问题标题】:"YTPlayerView.h" file not found when using YouTube-Player-iOS-Helper in Swift在 Swift 中使用 YouTube-Player-iOS-Helper 时找不到“YTPlayerView.h”文件
【发布时间】:2016-10-14 18:56:42
【问题描述】:

我遇到了与帖子YouTube-Player-iOS-Helper can't use YTPlayerView class 中相同的问题。 但是,在我按照同一帖子https://stackoverflow.com/a/30719229 中的答案在桥接头文件中导入“YTPlayerView.h”后,Xcode 说找不到“YTPlayerView.h”文件。

我用来安装“YouTube-Player-iOS-Helper”的 Podfile:

project 'YTSwift.xcodeproj'
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'

target 'YTSwift' do
  # Comment this line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for YTSwift
  pod "youtube-ios-player-helper"
end

target 'YTSwiftTests' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'YTSwiftUITests' do
    inherit! :search_paths
    # Pods for testing
  end

我的“Bridging-Header.h”:

//
//  Use this file to import your target's public headers that you would like to expose to Swift.
//

#import "YTPlayerView.h"

请告知如何解决此问题,谢谢! 如果有任何必要的文件内容供您参考,请告诉我。 谢谢!

【问题讨论】:

  • 先尝试使用 pod 构建,然后尝试导入。
  • @Dershowitz123 感谢您的回复。 “使用 pod 构建”是否意味着像 link 这样的切换方案然后构建?
  • 不,不要切换任何方案。安装 pod 并打开 .xcworkspace 后,只需按 command+B。然后尝试。有时 pod 不会链接到您的项目。构建项目会将其中的所有内容链接到
  • @Dershowitz123 好的。我会清理并删除派生数据,稍后再尝试构建。
  • @Dershowitz123 我在头文件中注释了"#import "YTPlayerView"这一行并进行了清理和删除,在不更改方案的情况下构建成功。但是,当我添加时问题仍然存在返回头文件中的“#import“YTPlayerView”行并再次构建。我的步骤正确吗?

标签: ios objective-c swift youtube


【解决方案1】:

尝试作为模块导入#import <youtube_ios_player_helper/YTPlayerView.h>

【讨论】:

  • 有点天哪!当我在我的 Xcode 项目中看到“youtube-ios-....”的虚线目录时,上面的下划线路径有效!
【解决方案2】:

指南中的引号类型错误。

我在尝试使用 #import “YTPlayerView.h” 导入时遇到了同样的问题

这个问题很难看,但与引号有关。他们是错误的类型。而是使用

#import "YTPlayerView.h"

【讨论】:

    【解决方案3】:

    让答案更清楚:

    您是否在目标级别设置了 Objective-C 桥接头设置?因为它必须设置在目标级别而不是而不是项目级别。如果你有,请确保你删除项目级别的设置。

    【讨论】:

    • @io̍k-úi TiuN,安装 pod 时,xcode 不会构建它。它只是作为另一个文件存在。您必须构建以使 xcode 意识到还有其他文件需要与此目标链接。只有这样你才能在桥接头中导入它。
    • 对不起,我弄糊涂了。就我而言,标头设置最初仅设置在 target 级别,并且无法通过以“header”作为关键字进行搜索在 project 级别找到。删除target级别的后,问题就解决了。
    【解决方案4】:

    我使用“youtube-ios-player-helperpod 'youtube-ios-player-helper', '~> 0.1',请用这个吊舱试试

    【讨论】:

    • 感谢您的建议。我以前试过这个,但问题还是一样。
    • pod 名称仍然是 pod 'youtube-ios-player-helper', '~> 0.1'。不要尝试 0.1.6
    【解决方案5】:

    最好包含最新版本的库,因为在 0.1 我遇到了类似的问题。

    解决办法,使用:pod "youtube-ios-player-helper", "~> 0.1.1"

    【讨论】:

    • 感谢您的建议,但是根据pod install echo消息安装了最新版本(0.1.6)。
    猜你喜欢
    • 2020-01-12
    • 2017-08-15
    • 2016-03-25
    • 2015-08-07
    • 2016-04-26
    • 2015-09-16
    • 1970-01-01
    • 2015-05-31
    • 2016-10-29
    相关资源
    最近更新 更多