YouTube-Player-iOS-Helper can't use YTPlayerView class
Asked Answered
O

2

11

I am trying to implement the youtube-ios-player-helper, found here: https://github.com/youtube/youtube-ios-player-helper

What I did: Edited my podfile, pod update, everything fine without any errors, Alamofire - which was also added via cocoapods still working

I can see the Pod in my workspace, and I can even select YTPlayerView as Class for my UIView in Storyboard

But when it comes to adding the IBOutlet it doesn't recognize the YTPlayerView Class anymore?!

storyboard collectionview cell

Shouldn't it be impossible to even select it in storyboard if the Pod wasnt properly added?

I also tried the "manual" method, that gave a slightly better result as it would let me define the Player, but wouldn't let me import the YTPlayerView via Bridging-Header

Oligopoly answered 26/5, 2015 at 2:11 Comment(0)
L
39

The YTPlayerView is in the separate Pods module which you need to import.

My Podfile:

platform :ios, '8.3'

target 'MyApp' do
    use_frameworks!
    pod 'youtube-ios-player-helper'
end

Your Swift file:

import UIKit
import youtube_ios_player_helper // You're missing this line

class MyView: UIView { // Some class

    @IBOutlet var playerView: YTPlayerView!

    // ...

}

If import youtube_ios_player_helper doesn't work for you, you can add #import "YTPlayerView.h" to your bridging header as stated in Fayza Nawaz's answer.

Lorusso answered 8/6, 2015 at 21:14 Comment(1)
You, the saviour!Imperialism
I
4

I faced the issue and fixed it by adding "#import YTPlayerView.h" in bridging header file in my project. To learn about bridging header, check this link: adding bridging header in swift ios. I hope it'll help you.

Iambus answered 8/7, 2015 at 10:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.