[Speech] Importing Speech framework does not weak-link it

Originator:sebastian.iosphere
Number:rdar://28008958 Date Originated:08/25/2016
Status:Closed Resolved:Yes (Xcode 8.2/iOS 10.2)
Product:Developer Tools Product Version:iOS 10
Classification:Crash Reproducible:Always
 
Summary:
We are building a framework that uses modern system frameworks, but also allows to deploy to older systems. We usually use `@import FrameworkName;` in code (ObjC), which also links the framework unless disabled in the host app's build settings.

We would expect @import to trigger weak-linking frameworks since that's the safe option. For some frameworks this is true, e.g., Intents, but the Speech framework is not weakly linked and therefore crashes on older systems.

Steps to Reproduce:
I have attached a sample project: It builds with the iOS 10 SDK, and runs on iOS 9 and 10.

Run it on iOS 9 (simulator is fine, reproduces on device, too, but requires additional configuration work for Intents)

Expected Results:
There are two classes that @import a framework that is only available on iOS 10. Both should log that the respective class is not available. None of the frameworks should be linked.

Actual Results:
The app crashes because the Speech framework could not be loaded.

If you disable the Speech class (remove the .m from the Compile Sources phase, and comment out the usage in the view controller), the app runs fine, i.e., the Intents framework handles it gracefully, as described in "Expected Results".

Version:
Xcode Version 8.0 beta 6 (8S201h)
OS X 10.11.6 (15G31)

Notes:
You can fix this by explicitly linking Intents, and setting it to optional. This works fine in single apps, but for a framework, it's much nicer if this works automatically and does not crash apps that forget to set this.

Configuration:
2.6 GHz Core i7
16 GB
NVIDIA GeForce GT 750M 2048 MB

Sample Project:
https://www.dropbox.com/s/qar8ilq31uk9l5y/SpeechImport.zip?dl=0

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!