Skip to content

Commit 4a4768a

Browse files
committed
fix: enable macOS framework linking by setting ObjC language mode
native_toolchain_c only passes -framework flags to clang when the language is objectiveC. Without this, IOKit/CoreFoundation/AppKit frameworks were silently dropped, causing undefined symbol errors on macOS. Also fix hidOpen test to use 0xFFFF/0xFFFF instead of 0/0, since VID/PID 0 is a wildcard that matches real devices on macOS.
1 parent 83a11ce commit 4a4768a

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

hook/build.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ void main(List<String> args) async {
3737
if (targetOS == OS.linux) '$sourcePath/linux/hid.c',
3838
],
3939
includes: ['$sourcePath/hidapi'],
40+
// native_toolchain_c only passes -framework flags when
41+
// language is set to objectiveC — plain C silently drops them.
42+
language: targetOS == OS.macOS ? Language.objectiveC : Language.c,
4043
frameworks: [
4144
if (targetOS == OS.macOS) 'IOKit',
4245
if (targetOS == OS.macOS) 'CoreFoundation',

test/hidapi_test.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,13 @@ void main() {
7878
}
7979
});
8080

81-
test('hidOpen throws HidException for invalid VID/PID', () {
81+
test('hidOpen with VID/PID 0xFFFF/0xFFFF throws HidException', () {
8282
hidInit();
8383
try {
84-
expect(() => hidOpen(0, 0), throwsA(isA<HidException>()));
84+
expect(
85+
() => hidOpen(0xFFFF, 0xFFFF),
86+
throwsA(isA<HidException>()),
87+
);
8588
} finally {
8689
hidExit();
8790
}

0 commit comments

Comments
 (0)