renzifeng / ZFPlayer

Support customization of any player SDK and control layer(支持定制任何播放器SDK和控制层)
MIT License
7.07k stars 1.75k forks source link

swift3 遇到 “dyld: Symbol not found: _OBJC_CLASS_$_ZFAVPlayerManager” #691

Closed AniOSDeveloper closed 5 years ago

AniOSDeveloper commented 5 years ago

如题,在 Xcode10.1 中使用 swift3 的 pod 集成方式,podfile 中已添加如下内容

pod 'ZFPlayer', '~> 3.2.4'
pod 'ZFPlayer/ControlView', '~> 3.0'
pod 'ZFPlayer/AVPlayer', '~> 3.0'

安装完成后,可在 podfile 中找到 ZFAVPlayerManager 类,并在代码中可通过 ^ + ⌘ 跳转到此类头文件。 运行后 collectionview 未出现即显示如上崩溃信息,swift3 中做如下设置:

override func viewDidLoad() {
    super.viewDidLoad()
    let currentUrl = URL.init(string: "http://tb-video.bdstatic.com/tieba-movideo/11233547_ac127ce9e993877dce0eebceaa04d6c2_593d93a619b0.mp4")!

    let playerManager = ZFAVPlayerManager.init()

    player = ZFPlayerController.init(scrollView: currentCollectionViewOfBottom!, playerManager: playerManager, containerViewTag: tagOfCellImageView)
    player?.shouldAutoPlay = true
    controlView = ZFPlayerControlView.init()
    player?.controlView = controlView!
    player?.assetURL = currentUrl
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: CollectionViewVideoCellID, for: indexPath) as! CollectionViewVideoCell

   self.player?.playTheIndexPath(indexPath, scrollToTop: false)

    return cell
}
AniOSDeveloper commented 5 years ago

改用手动方式集成也会崩掉: 将 ZFPlayer 目录下的 core、player 和 controlview 文件夹拖拽到工程内,仍然使用如上代码,运行后会停在 ZFAVPlayerManager.m 的 presentView.player = _player 行,控制台有如下提示:

[MediaRemote] [AVOutputContext] WARNING: AVF context unavailable for SYSTEM
[framework] CUIThemeStore: No theme registered with id=0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'An AVPlayerItem cannot be associated with more than one instance of AVPlayer'
AniOSDeveloper commented 5 years ago

找到 “dyld: Symbol not found: _OBJCCLASS$_ZFAVPlayerManager” 的解决方法了! 网上别人的说法是在将第三方库(ZFAVPlayer)或 Fondation 改为 optional,测试均不可行。 忽然想到可能和版本有关系,将 deployment target 改成9.0后,能运行起来了! 但是应用需要支持iOS8,不得已还得改回来,但是运行后它仍然能起来! 这是怎么回事?诡异诡异!!!

renzifeng commented 5 years ago

关于swift的兼容性 没做测试

lhf19900402 commented 1 year ago

大神!何时支持 swift ?