dyld not found AVAssetDownladTask
Asked Answered
T

3

13

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!

Tournai answered 24/3, 2017 at 21:4 Comment(0)
T
12

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.

Tournai answered 27/3, 2017 at 18:11 Comment(2)
so the solution is: add AVFoundation to 'Link Binary With Libraries' with optional setting?Isaacs
No it's not, (or it's not what I did at least) The steps are described in the the link and the comment I posted.Tournai
H
6

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

Hyper answered 7/11, 2019 at 15:8 Comment(0)
A
1

This picture shows how to weak link a framework:

how to weak link a framework

Ammeter answered 26/5, 2020 at 13:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.