[iOS] dyld - it loads a framework with a higher minimum OS support

Our app supports iOS12 as the minimum OS and we embed a framework with iOS15 minimum support. Naturally we weak-link it and use #available(iOS 15, ) to guard accesses to its symbols.

On iOS12.5.7 the framework is completely ignored and the app works fine. On iOS13.3.1 however we get to see this error:

  Termination Description: DYLD, dependent dylib '/System/Library/Frameworks/AVFAudio.framework/AVFAudio' not found for '/private/var/containers/Bundle/Application/08DA2D93-4DC2-4523-98AF-FD52884989AE/<OUR_APP>.app/Frameworks/<FRAMEWORK>.framework/<FRAMEWORK>', tried but didn't find: '/System/Library/Frameworks/AVFAudio.framework/AVFAudio' '/System/Library/Frameworks/AVFAudio.framework/AVFAudio'

<FRAMEWORK> has a dependency on AVFAudio which is available only since iOS 14.5 so it makes sense it wouldn;t be able to find it but what's bothering us is why does dyld even try loading the <FRAMEWORK>'s dependencies instead of just ignoring it?

Could this be a bug on 13.3.1? Unfortunately at this time we don't have other iOS13 phones to test with.

The 'LC_BUILD_VERSION' command sure enough seems valid::

Load command 10 cmd LC_BUILD_VERSION cmdsize 32 platform 2 minos 15.0 sdk 17.0 ntools 1 tool 3 version 1015.7

Answered by DTS Engineer in 831933022

I suspect you're hitting an issue with how we link the AVFAudio framework on a narrow range of iOS versions, so that's likely why you see things correctly ignored for your app on iOS 12, but not iOS 13. I suspect you'll see this crash on versions of iOS 14 prior to iOS 14.5 too.

We'd appreciate a bug report on that. If you can create a small test project where you have a framework with a deployment target of iOS 15, and app target of something older, and just a small amount of AVFAudio code in the framework to demonstrate the crash, that's even better. If you can file that report, please post the FB number here.

If I'm correct about the root cause of what you're seeing, the workaround is to raise the deployment target of the app to iOS 14.5 or above.

— Ed Ford,  DTS Engineer

Unfortunately at this time we don't have other iOS 13 phones to test with.

Do you have an iOS 14 device to try this on?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Hi @DTS Engineer , no unfortunately we don't have one right now. We are trying to find unopened iPhone 12 / iPhone 11 devices to buy, to have them in their initial iOS14/iOS13 state but most of the stores so far are out of stock.

Does factory resetting iPhones put them in their original OS version?

Accepted Answer

I suspect you're hitting an issue with how we link the AVFAudio framework on a narrow range of iOS versions, so that's likely why you see things correctly ignored for your app on iOS 12, but not iOS 13. I suspect you'll see this crash on versions of iOS 14 prior to iOS 14.5 too.

We'd appreciate a bug report on that. If you can create a small test project where you have a framework with a deployment target of iOS 15, and app target of something older, and just a small amount of AVFAudio code in the framework to demonstrate the crash, that's even better. If you can file that report, please post the FB number here.

If I'm correct about the root cause of what you're seeing, the workaround is to raise the deployment target of the app to iOS 14.5 or above.

— Ed Ford,  DTS Engineer

Ok so we managed to install it on an iOS14.4 phone using a cloud mobile testing service and it crashed there too.

Unfortunately the app still has to support versions as old as iOS12 so raising the minimum to iOS14.5 is not that feasible.

So what I did instead was to unlink this sdk from the app target and extract all the code that imports it into a separate new framework. This new framework will be the one to link to the sdk and it will be manually loaded(via Bundle.load() if the guard for iOS15 passes, with its utilities created via NSClassFromString .

[iOS] dyld - it loads a framework with a higher minimum OS support
 
 
Q