Skip to content

Commit a38f46e

Browse files
madsmtmsimlay
authored andcommitted
Fix AudioUnit linking on iOS
On iOS, the AudioUnit framework is not (and newer were) linkable, instead one should link to AudioToolbox. Source: https://stackoverflow.com/a/14120936 Verified by looking at simulator runtimes (this is what I could find) for version 9.3 and 10.3, on both of these AudioUnit does not contain a dylib (unlike most other frameworks). Also, in the SDK it's missing an AudioUnit.tbd file in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/AudioUnit.framework
1 parent dcfcfc7 commit a38f46e

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

build.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,23 @@ fn build(sdk_path: Option<&str>, target: &str) {
4949

5050
#[cfg(feature = "audio_unit")]
5151
{
52-
println!("cargo:rustc-link-lib=framework=AudioUnit");
52+
// Since iOS 10.0 and macOS 10.12, all the functionality in AudioUnit
53+
// moved to AudioToolbox, and the AudioUnit headers have been simple
54+
// wrappers ever since.
55+
if target.contains("apple-ios") {
56+
// On iOS, the AudioUnit framework does not have (and never had) an
57+
// actual dylib to link to, it is just a few header files.
58+
// The AudioToolbox framework contains the symbols instead.
59+
println!("cargo:rustc-link-lib=framework=AudioToolbox");
60+
} else {
61+
// On macOS, the symbols are present in the AudioToolbox framework,
62+
// but only on macOS 10.12 and above.
63+
//
64+
// However, unlike on iOS, the AudioUnit framework on macOS
65+
// contains a dylib with the desired symbols, that we can link to
66+
// (in later versions just re-exports from AudioToolbox).
67+
println!("cargo:rustc-link-lib=framework=AudioUnit");
68+
}
5369
headers.push("AudioUnit/AudioUnit.h");
5470
}
5571

0 commit comments

Comments
 (0)