1

I encountered the same problem as in the post YouTube-Player-iOS-Helper can't use YTPlayerView class . However, after I followed the answer in the same post https://stackoverflow.com/a/30719229 to import "YTPlayerView.h" in the bridging header file, Xcode said that "YTPlayerView.h" file not found.

Podfile that I used to install "YouTube-Player-iOS-Helper":

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

My "Bridging-Header.h":

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

#import "YTPlayerView.h"

Please advise how to fix this problem, thank you! If there is any file contents necessary for your reference, please let me know. Thank you!

Community
  • 1
  • 1
  • Try building with the pod first and then try importing. – Mtoklitz113 Jun 14 '16 at 07:15
  • @Dershowitz123 Thank you for your reply. Does "building with the pod" mean switch schemes like this [link](http://imgur.com/NS2CywI) and then build? – io̍k-úi TiuN Jun 14 '16 at 07:23
  • No don't switch any schemes. Once the pods are installed and u open the .xcworkspace, just hit command+B. Then try. Sometimes pods won't be linked to your project. Building the project will link everything in it **to** it. – Mtoklitz113 Jun 14 '16 at 07:25
  • @Dershowitz123 OK. I'll do a clean and delete the derived data, and try to build soon later. – io̍k-úi TiuN Jun 14 '16 at 07:27
  • @Dershowitz123 I commented the line "#import "YTPlayerView" in the header file and made the clean and deletion, and I have a successful building without changing schemes. However, the problem still occurred when I add back the line "#import "YTPlayerView" in the header file and builded again. Are my steps right? – io̍k-úi TiuN Jun 14 '16 at 07:33
  • Have you set the `Objective-C Bridging Header` setting at the target level? Because it has to be set at the project level and **not** the target level. If you've, make sure u delete the setting at project level. – Mtoklitz113 Jun 14 '16 at 07:44
  • @Dershowitz123 Yes I have. Did you mean delete the setting at **target** or **project** level? You said the setting should not at the **target** level. – io̍k-úi TiuN Jun 14 '16 at 07:53
  • Yeah sorry I meant it has to be set at Target level and not the project level. My Bad. Still not working? – Mtoklitz113 Jun 14 '16 at 08:01
  • @Dershowitz123 That's OK. I deleted it and it seems every thing became great. Amazing! Thank you!! – io̍k-úi TiuN Jun 14 '16 at 08:04
  • @Dershowitz123 In addition, still have some questions, just for a clarification for my concept. At first I add the header setting at the target level , while Pods is out of the scope of the target. Is that why the header cannot "see" the "YTPlayerView.h" located in Pods? – io̍k-úi TiuN Jun 14 '16 at 08:11

5 Answers5

3

try to import as a module #import <youtube_ios_player_helper/YTPlayerView.h>

Deepak
  • 31
  • 4
0

i using "youtube-ios-player-helper" with pod 'youtube-ios-player-helper', '~> 0.1', please try with this pod

Jagveer Singh
  • 2,258
  • 19
  • 34
0

Better include the newest version of the library, because on 0.1 I had similar problems.

Solution, use: pod "youtube-ios-player-helper", "~> 0.1.1"

kchromik
  • 1,348
  • 2
  • 13
  • 42
-1

Making the answer more clear:

Have you set the Objective-C Bridging Header setting at the target level? Because it has to be set at the Target level and not the Project level. If you've, make sure u delete the setting at project level.

Mtoklitz113
  • 3,828
  • 3
  • 21
  • 40
  • @io̍k-úi TiuN, When the pods are installed, xcode doesn't build it. It'll just be there as another file. You have to build for in order for xcode to realise that there are additional files which need to be linked with this target. Only then you can import it in the bridging header. – Mtoklitz113 Jun 14 '16 at 08:14
  • Sorry, I got confused. In my case, the header setting was originally set at **target** level only, and cannot be found at the _project_ level by searching with "header" as a keyword. After deleting the one at **target** level, the problem was fixed. – io̍k-úi TiuN Jun 14 '16 at 08:47
-1

The type of quotation marks are wrong in the guide.

I had the same problem with trying to import with #import “YTPlayerView.h”

The problem was very difficult to see but has to do with the quotation marks. They are the wrong type. Instead use

#import "YTPlayerView.h"
Christoffer
  • 7,436
  • 4
  • 40
  • 42