From 1820a051f845dc37334b62ea8f54b2293c078e0e Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Fri, 3 May 2024 12:29:31 +1000 Subject: [PATCH] don't use withUnsafeBytes(of:), seems to not work properly on Linux --- .../FlutterSwift/Messenger/FlutterDesktopMessenger.swift | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Sources/FlutterSwift/Messenger/FlutterDesktopMessenger.swift b/Sources/FlutterSwift/Messenger/FlutterDesktopMessenger.swift index e89db66..dfde1e7 100644 --- a/Sources/FlutterSwift/Messenger/FlutterDesktopMessenger.swift +++ b/Sources/FlutterSwift/Messenger/FlutterDesktopMessenger.swift @@ -64,7 +64,9 @@ public actor FlutterDesktopMessenger: FlutterBinaryMessenger { ) throws { precondition(isAvailable) - guard withUnsafeBytes(of: message, { bytes in + let message = [UInt8](message ?? Data()) + + guard message.withUnsafeBytes({ bytes in // run on main actor, so don't need to take lock FlutterDesktopMessengerSendWithReplyBlock( messenger, @@ -101,12 +103,13 @@ public actor FlutterDesktopMessenger: FlutterBinaryMessenger { } // FIXME: do we need to take a lock here? doesn't look like other platforms do - withUnsafeBytes(of: response) { + let response = [UInt8](response ?? Data()) + response.withUnsafeBytes { FlutterDesktopMessengerSendResponse( messenger, handle, $0.baseAddress, - response?.count ?? 0 + response.count ) } }