Skip to content

Commit f7f7b02

Browse files
authored
Merge pull request #51 from madsmtm/fix-audiounit-linking
Fix AudioUnit linking
2 parents 6602318 + ef76b05 commit f7f7b02

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

.github/workflows/coreaudio-sys.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ jobs:
44
# Run cargo test with default, no and all features.
55
macos-test:
66
runs-on: macOS-latest
7+
strategy:
8+
matrix:
9+
toolchain: [stable, nightly]
710
steps:
811
- uses: actions/checkout@v2
912
- name: Install llvm and clang
@@ -12,7 +15,7 @@ jobs:
1215
uses: actions-rs/toolchain@v1
1316
with:
1417
profile: minimal
15-
toolchain: stable
18+
toolchain: ${{ matrix.toolchain }}
1619
override: true
1720
- name: cargo test
1821
run: cargo test --verbose

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "coreaudio-sys"
3-
version = "0.2.8"
3+
version = "0.2.9"
44
authors = ["Mitchell Nordine <mitchell.nordine@gmail.com>"]
55
description = "Bindings for Apple's CoreAudio frameworks generated via rust-bindgen"
66
license = "MIT"

build.rs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,32 @@ fn build(sdk_path: Option<&str>, target: &str) {
4747

4848
let mut headers: Vec<&'static str> = vec![];
4949

50-
#[cfg(feature = "audio_toolbox")]
50+
#[cfg(feature = "audio_unit")]
5151
{
52-
println!("cargo:rustc-link-lib=framework=AudioToolbox");
53-
headers.push("AudioToolbox/AudioToolbox.h");
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+
}
69+
headers.push("AudioUnit/AudioUnit.h");
5470
}
5571

56-
#[cfg(feature = "audio_unit")]
72+
#[cfg(feature = "audio_toolbox")]
5773
{
5874
println!("cargo:rustc-link-lib=framework=AudioToolbox");
59-
headers.push("AudioUnit/AudioUnit.h");
75+
headers.push("AudioToolbox/AudioToolbox.h");
6076
}
6177

6278
#[cfg(feature = "core_audio")]

0 commit comments

Comments
 (0)