0

As the question states, I'm trying to use this module in my Swift project using the use_frameworks! option on my Podfile. Like so:

platform :ios, "8.0"
source 'https://github.com/CocoaPods/Specs.git'

use_frameworks!

pod 'youtube-ios-player-helper', '~> 0.1.3'
pod 'ReactiveCocoa', '3.0-beta.6'
pod 'Moya'
pod 'Moya/Reactive'

I have checked the Pods project and it has a framework called youtube_ios_player_helper.framework since - is an invalid character for the name. But when I add import youtube_ios_player_helper to my Swift file I get an error saying it does not exist.

I must say that I have some Obj-C code in my project and because of this I also have a bridging header file in the project.

JAL
  • 41,701
  • 23
  • 172
  • 300
alcarv
  • 889
  • 6
  • 15
  • Which version of Cocoapods are you using? – JAL Jun 04 '15 at 16:34
  • I'm using 0.37.2. It turns out the problem was in the Pods configuration. It was not being included in the project because of missing architectures. I had to turn off "Build only target architecture" for Debug mode. The code has so many warnings that I missed this one. Legacy code in Swift, that's a new one for me! – alcarv Jun 04 '15 at 19:05

2 Answers2

1

Make sure you're adding the library to the correct target.

My Podfile:

platform :ios, '8.3'

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

ViewController.swift:

import UIKit
import youtube_ios_player_helper

class ViewController: UIViewController {

    // ...

    override func viewDidLoad() {
        super.viewDidLoad()

        let myView = YTPlayerView()

        // ...
    }

    // ...

}

If the pure swift import import youtube_ios_player_helper doesn't work, adding #import "YTPlayerView.h" to your application's bridging header should have the same effect of bridging the YouTube helper class to Swift.

JAL
  • 41,701
  • 23
  • 172
  • 300
  • As I said in a comment above it was actually another problem. The Pods framework was not being included because of missing architecture, informed by XCode in a warning which is bad, in my opinion. After solving that, it worked without the need to specify a target, though. – alcarv Jun 05 '15 at 11:35
1

Answer by the OP in the comments on their question:

It turns out the problem was in the Pods configuration. It was not being included in the project because of missing architectures. I had to turn off "Build only target architecture" for Debug mode. The code has so many warnings that I missed this one. Legacy code in Swift, that's a new one for me!

JAL
  • 41,701
  • 23
  • 172
  • 300