2016-06-14 118 views
1

我遇到了與帖子YouTube-Player-iOS-Helper can't use YTPlayerView class中相同的問題。 但是,當我在後面的回答中發現https://stackoverflow.com/a/30719229在橋接頭文件中導入「YTPlayerView.h」時,Xcode表示找不到「YTPlayerView.h」文件。在Swift中使用YouTube-Player-iOS-Helper時找不到「YTPlayerView.h」文件

Podfile我用來安裝 「的YouTube播放器,IOS的助手」:

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 

我的 「橋接-Header.h」:

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

#import "YTPlayerView.h" 

請告知如何解決這個問題, 謝謝! 如果有任何必要的文件內容供您參考,請讓我知道。 謝謝!

+0

嘗試先用莢建設,然後嘗試導入。 – Dershowitz123

+0

@ Dershowitz123感謝您的回覆。 「建立與pod」意味着切換方案像這樣[鏈接](http://imgur.com/NS2CywI),然後建立? –

+0

不可以切換任何方案。一旦安裝了pod並打開.xcworkspace,只需點擊命令+ B即可。然後嘗試。有時吊艙不會與您的項目相關聯。構建該項目將把它中的所有內容鏈接到**。 – Dershowitz123

回答

0

我使用「youtube-ios-player-helper」與 pod 'youtube-ios-player-helper', '~> 0.1',請與該吊艙

+0

謝謝您的建議。我之前嘗試過,但問題仍然如此。 –

+0

pod name仍然是pod'youtube-ios-player-helper','〜> 0.1'。不要嘗試0.1.6 –

0

嘗試更好地包括庫的最新版本,因爲0.1我有類似的問題。

解決方案,使用方法:pod "youtube-ios-player-helper", "~> 0.1.1"

+0

感謝您的建議,但根據pod安裝回顯消息安裝了最新版本(0.1.6)。 –

0

使答案更加明確:

是否設置爲Objective-C的橋接報在目標級別設置?因爲它必須設置在目標級別而不是項目級別。如果你有,請確保你在項目級別刪除設置。

+0

@io̍k-úiTiuN,當安裝pod時,xcode不會構建它。它只會作爲另一個文件在那裏。你必須爲了讓xcode意識到有額外的文件需要與這個目標鏈接而建立。只有這樣您才能將其導入到橋接頭中。 – Dershowitz123

+0

對不起,我很困惑。在我的情況下,標題設置最初僅設置爲**目標**級別,並且通過使用「標題」作爲關鍵字進行搜索,不能在_project_級別找到。刪除**目標**級別的問題後,問題得到解決。 –

0

指南中的引號類型是錯誤的。

我有同樣的問題,試圖用#進口「YTPlayerView.h」

的問題是很難看到的,但有帶引號做進口。他們是錯誤的類型。而是使用

#import "YTPlayerView.h" 
1

嘗試導入作爲一個模塊#import <youtube_ios_player_helper/YTPlayerView.h>

相關問題