Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dyld not found AVAssetDownladTask

Trying to add offline HLS (a new ios 10 feature) to an app. I'm trying the following in swift in order for the app to still function on ios 9 without the offline HLS Functionality. Works fine on ios10 and compiles for ios9 too.

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

However, when I actually run this on a ios 9 device, the app crashes immediately with the following message :

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

I've constrained all code related to this to the DownloadManager class so i dunno what to do next. Thanks!

like image 837
NickDK Avatar asked Mar 24 '17 21:03

NickDK


2 Answers

I figured it out. I had to weak link AVFoundation. Found it on apple's site.

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.

like image 198
NickDK Avatar answered Nov 16 '22 12:11

NickDK


I had same issue and I weak linked the AVFoundation framework Below is the step

add -weak_framework AVfoundation in "other linker flags" in Build settings

like image 5
V V Avatar answered Nov 16 '22 12:11

V V