如何使用use_frameworks使用YouTube iOS播放器助手!使用CocoaPods



正如问题所述,我正试图在Swift项目中使用Podfile上的use_frameworks!选项来使用此模块。像这样:

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'

我已经检查了Pods项目,它有一个名为youtube_ios_player_helper.framework的框架,因为-是名称的无效字符。但是当我把import youtube_ios_player_helper添加到Swift文件中时,我得到一个错误,说它不存在。

我必须说,我的项目中有一些Obj-C代码,因此我在项目中也有一个桥接头文件。

确保将库添加到正确的目标。

我的播客文件:

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()
        // ...
    }
    // ...
}

如果纯swift导入import youtube_ios_player_helper不起作用,那么将#import "YTPlayerView.h"添加到应用程序的桥接头中应该具有将YouTube助手类桥接到swift的效果。

OP在评论中对其问题的回答:

事实证明,问题出在Pods配置中。由于缺少体系结构,它没有包含在项目中。我不得不为调试模式关闭"只构建目标体系结构"。代码中有太多的警告,以至于我错过了这一条。Swift中的遗留代码,这对我来说是一个新代码!

最新更新