dyld 未找到 AVAssetDownladTask

dyld not found AVAssetDownladTask

正在尝试向应用添加离线 HLS(一项新的 ios 10 功能)。我正在 swift 中尝试以下操作,以便应用程序在没有离线 HLS 功能的情况下仍能在 ios 9 上运行。在 ios10 上工作正常,也可以为 ios9 编译。

    @available(iOS 10.0, *)
    @objc class DownloadManager: NSObject, AVAssetDownloadDelegate {
           //Do stuff with downloading assets
      }

但是,当我实际上 运行 在 ios 9 设备上执行此操作时,应用程序立即崩溃并显示以下消息:

dyld: Symbol not found: _OBJC_CLASS_$_AVAssetDownloadTask Referenced from: /var/mobile/Containers/Bundle/Application/7062C410-C4F5-4270-9F1E-22750E99F799/wod.app/wod Expected in: /System/Library/Frameworks/AVFoundation.framework/AVFoundation in /var/mobile/Containers/Bundle/Application/7062C410-C4F5-4270-9F1E-22750E99F799/wod.app/wod

我已将与此相关的所有代码都限制到 DownloadManager class 所以我不知道下一步该做什么。谢谢!

我明白了。我不得不削弱 link AVFoundation。在 apple 的网站上找到它。

https://developer.apple.com/library/content/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html

Weak Linking to Entire Frameworks

When you reference symbols in another framework, most of those symbols are linked strongly to your code. In order to create a weak link to a symbol, the framework containing the symbol must explicitly add the weak_import attribute to it (see Marking Symbols for Weak Linking). However, if you do not maintain a framework and need to link its symbols weakly, you can explicitly tell the compiler to mark all symbols as weakly linked. To do this, you must open your project in Xcode and modify the way your targets link to the framework as follows:

Select the target you want to modify and reveal its build phases. Expand the Link Binary With Libraries build phase to view the frameworks currently linked by the target. If the framework you want to weakly link to is listed in the Link Binary With Libraries build phase, select it, and choose Edit > Delete to remove it. Now you can tell the linker to use weak linking for that framework.

Select the target, open its Info window, and click Build. To the Other Linker Flags build setting, add the following command-line option specification, where is the name of the framework you want to weakly link to: -weak_framework Build your product.

我有同样的问题,我弱链接了 AVFoundation 框架 下面是步骤

在构建设置"other linker flags"中添加-weak_framework AVfoundation

这张图片展示了如何削弱link一个框架: