Skip to content

Commit aefde05

Browse files
committed
Fix NSUUID issue on Linux platform
1 parent 4c833cb commit aefde05

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

Package.resolved

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Sources/OpenBox/OBUUID.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,22 @@
66
#define OBUUID_hpp
77

88
#include "OBBase.h"
9+
10+
#if OB_TARGET_OS_DARWIN
911
#include <Foundation/Foundation.h>
12+
#endif
1013

1114
typedef struct OBUUID {
1215
uint8_t bytes[16];
1316
} OBUUID;
1417

1518
OB_EXTERN_C_BEGIN
1619

20+
#if OB_TARGET_OS_DARWIN
1721
OB_EXPORT
1822
OB_REFINED_FOR_SWIFT
1923
OBUUID OBUUIDInitFromNSUUID(NSUUID *uuid) OB_SWIFT_NAME(OBUUID.init(uuid:));
24+
#endif
2025

2126
OB_EXPORT
2227
OB_REFINED_FOR_SWIFT

Sources/OpenBox/OBUUID.mm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44

55
#include "OBUUID.h"
66

7+
#if OB_TARGET_OS_DARWIN
78
OBUUID OBUUIDInitFromNSUUID(NSUUID *uuid) {
89
OBUUID ob_uuid;
910
[uuid getUUIDBytes:ob_uuid.bytes];
1011
return ob_uuid;
1112
}
13+
#endif
1214

1315
OBUUID OBUUIDInitFromHash(uint64_t words0, uint64_t words1, uint32_t words2) {
1416
OBUUID ob_uuid;

Tests/OpenBoxCompatibilityTests/UUIDTests.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ struct UUIDTests {
2626
]
2727
),
2828
])
29-
func foundationUUID(uuid: UUID, expectedBytes: [UInt8]) async throws {
29+
func foundationUUID(uuid: UUID, expectedBytes: [UInt8]) {
30+
#if canImport(Darwin)
3031
let id = OBUUID(uuid: uuid)
3132
let bytes = id.bytes
3233
#expect(bytes.0 == expectedBytes[0])
@@ -45,6 +46,11 @@ struct UUIDTests {
4546
#expect(bytes.13 == expectedBytes[13])
4647
#expect(bytes.14 == expectedBytes[14])
4748
#expect(bytes.15 == expectedBytes[15])
49+
#else
50+
withKnownIssue {
51+
Issue.record("NSUUID supported on non-Darwin platforms")
52+
}
53+
#endif
4854
}
4955

5056
@Test(arguments: [
@@ -76,7 +82,7 @@ struct UUIDTests {
7682
]
7783
),
7884
])
79-
func strongHashUUID(words: (UInt32, UInt32, UInt32, UInt32, UInt32), expectedBytes: [UInt8]) async throws {
85+
func strongHashUUID(words: (UInt32, UInt32, UInt32, UInt32, UInt32), expectedBytes: [UInt8]) {
8086
let id: OBUUID = OBUUID(hash: UInt64(words.0) | UInt64(words.1) &<< 32, UInt64(words.2) | UInt64(words.3) &<< 32, words.4)
8187
let bytes = id.bytes
8288
#expect(bytes.0 == expectedBytes[0])

0 commit comments

Comments
 (0)