Skip to content

Commit

Permalink
Merge #88
Browse files Browse the repository at this point in the history
88: Debug on iOS device, Xcode alway Throw error r=kvark a=grenlight

When use ```aarch64-apple-ios``` buid and debug on iOS device, Xcode alway Throw error: ```Undefined symbols for architecture arm64:
"_MTLCopyAllDevices"```

Co-authored-by: li jinlei <[email protected]>
  • Loading branch information
bors[bot] and jinleili committed Jul 16, 2019
2 parents 1c92416 + 2424c20 commit cbf920c
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1343,6 +1343,7 @@ bitflags! {
#[link(name = "Metal", kind = "framework")]
extern "C" {
fn MTLCreateSystemDefaultDevice() -> *mut MTLDevice;
#[cfg(not(target_os = "ios"))]
fn MTLCopyAllDevices() -> *mut Object; //TODO: Array
}

Expand Down Expand Up @@ -1393,19 +1394,21 @@ impl Device {
unsafe { Device(MTLCreateSystemDefaultDevice()) }
}

#[cfg(target_os = "ios")]
pub fn all() -> Vec<Device> {
if cfg!(target_os = "ios") {
vec![Device::system_default()]
} else {
unsafe {
let array = MTLCopyAllDevices();
let count: NSUInteger = msg_send![array, count];
let ret = (0..count)
.map(|i| msg_send![array, objectAtIndex: i])
.collect();
msg_send![array, release];
ret
}
vec![Device::system_default()]
}

#[cfg(not(target_os = "ios"))]
pub fn all() -> Vec<Device> {
unsafe {
let array = MTLCopyAllDevices();
let count: NSUInteger = msg_send![array, count];
let ret = (0..count)
.map(|i| msg_send![array, objectAtIndex: i])
.collect();
msg_send![array, release];
ret
}
}
}
Expand Down

0 comments on commit cbf920c

Please sign in to comment.