Skip to content

Commit 80efa16

Browse files
committed
Fix linking in objc_id
1 parent 6264909 commit 80efa16

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

objc_id/src/id.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,25 @@ mod tests {
206206
use objc::runtime::Object;
207207
use objc::{class, msg_send};
208208

209+
#[cfg(not(target_vendor = "apple"))]
210+
use objc::runtime::Class;
211+
212+
#[cfg(not(target_vendor = "apple"))]
213+
#[link(name = "gnustep-base", kind = "dylib")]
214+
extern "C" {}
215+
216+
// TODO: Remove the need for this hack
217+
#[cfg(not(target_vendor = "apple"))]
218+
extern "C" {
219+
static _OBJC_CLASS_NSObject: Class;
220+
}
221+
222+
#[cfg(not(target_vendor = "apple"))]
223+
#[test]
224+
fn get_class_to_force_linkage() {
225+
unsafe { &_OBJC_CLASS_NSObject };
226+
}
227+
209228
fn retain_count(obj: &Object) -> usize {
210229
unsafe { msg_send![obj, retainCount] }
211230
}

objc_id/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ which can be cloned to allow multiple references.
1111
1212
Weak references may be created using the [`WeakId`](struct.WeakId.html) struct.
1313
14-
```
14+
```no_run
1515
# use objc::msg_send;
1616
use objc::runtime::{Class, Object};
1717
use objc_id::{Id, WeakId};

0 commit comments

Comments
 (0)