@@ -11,7 +11,12 @@ fn sdk_path(target: &str) -> Result<String, std::io::Error> {
1111
1212 let sdk = if target. contains ( "apple-darwin" ) {
1313 "macosx"
14- } else if target. contains ( "apple-ios" ) {
14+ } else if target == "x86_64-apple-ios" || target == "i386-apple-ios" {
15+ "iphonesimulator"
16+ } else if target == "aarch64-apple-ios"
17+ || target == "armv7-apple-ios"
18+ || target == "armv7s-apple-ios"
19+ {
1520 "iphoneos"
1621 } else {
1722 unreachable ! ( ) ;
@@ -47,14 +52,19 @@ fn build(sdk_path: Option<&str>, target: &str) {
4752
4853 #[ cfg( feature = "audio_unit" ) ]
4954 {
50- println ! ( "cargo:rustc-link-lib=framework=AudioUnit " ) ;
55+ println ! ( "cargo:rustc-link-lib=framework=AudioToolbox " ) ;
5156 headers. push ( "AudioUnit/AudioUnit.h" ) ;
5257 }
5358
5459 #[ cfg( feature = "core_audio" ) ]
5560 {
5661 println ! ( "cargo:rustc-link-lib=framework=CoreAudio" ) ;
57- headers. push ( "CoreAudio/CoreAudio.h" ) ;
62+
63+ if target. contains ( "apple-ios" ) {
64+ headers. push ( "CoreAudio/CoreAudioTypes.h" ) ;
65+ } else {
66+ headers. push ( "CoreAudio/CoreAudio.h" ) ;
67+ }
5868 }
5969
6070 #[ cfg( feature = "open_al" ) ]
@@ -79,13 +89,27 @@ fn build(sdk_path: Option<&str>, target: &str) {
7989 // Begin building the bindgen params.
8090 let mut builder = bindgen:: Builder :: default ( ) ;
8191
92+ // See https://github.com/rust-lang/rust-bindgen/issues/1211
93+ // Technically according to the llvm mailing list, the argument to clang here should be
94+ // -arch arm64 but it looks cleaner to just change the target.
95+ let target = if target == "aarch64-apple-ios" {
96+ "arm64-apple-ios"
97+ } else {
98+ target
99+ } ;
82100 builder = builder. size_t_is_usize ( true ) ;
83101
84102 builder = builder. clang_args ( & [ & format ! ( "--target={}" , target) ] ) ;
85103
86104 if let Some ( sdk_path) = sdk_path {
87105 builder = builder. clang_args ( & [ "-isysroot" , sdk_path] ) ;
88106 }
107+ if target. contains ( "apple-ios" ) {
108+ // time.h as has a variable called timezone that conflicts with some of the objective-c
109+ // calls from NSCalendar.h in the Foundation framework. This removes that one variable.
110+ builder = builder. blacklist_item ( "timezone" ) ;
111+ builder = builder. blacklist_item ( "objc_object" ) ;
112+ }
89113
90114 let meta_header: Vec < _ > = headers
91115 . iter ( )
@@ -95,9 +119,7 @@ fn build(sdk_path: Option<&str>, target: &str) {
95119 builder = builder. header_contents ( "coreaudio.h" , & meta_header. concat ( ) ) ;
96120
97121 // Generate the bindings.
98- builder = builder
99- . trust_clang_mangling ( false )
100- . derive_default ( true ) ;
122+ builder = builder. trust_clang_mangling ( false ) . derive_default ( true ) ;
101123
102124 let bindings = builder. generate ( ) . expect ( "unable to generate bindings" ) ;
103125
0 commit comments