From e1dafe0cf96d69c357387552cd01658cbf337fea Mon Sep 17 00:00:00 2001 From: iborusik Date: Sat, 6 Jun 2026 12:41:43 +0200 Subject: [PATCH 1/4] Fix undefined symbols on release build. Mark symbols as used and public. --- Example/LocalLLMClientExample/ChatView.swift | 2 ++ Sources/LocalLLMClientLlama/stb_image.swift | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Example/LocalLLMClientExample/ChatView.swift b/Example/LocalLLMClientExample/ChatView.swift index 1103a56..0b8cb5d 100644 --- a/Example/LocalLLMClientExample/ChatView.swift +++ b/Example/LocalLLMClientExample/ChatView.swift @@ -112,6 +112,7 @@ struct ChatBubbleView: View { } } +#if DEBUG #Preview("Text") { @Previewable @State var ai: AI = { let ai = AI() @@ -128,6 +129,7 @@ struct ChatBubbleView: View { } .environment(ai) } +#endif extension LLMAttachment { static let imagePreview = try! Self.image(LLMInputImage(data: .init(contentsOf: URL(string: "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/cats.jpeg")!))!) diff --git a/Sources/LocalLLMClientLlama/stb_image.swift b/Sources/LocalLLMClientLlama/stb_image.swift index d377e95..3923b09 100644 --- a/Sources/LocalLLMClientLlama/stb_image.swift +++ b/Sources/LocalLLMClientLlama/stb_image.swift @@ -3,8 +3,9 @@ import Accelerate import CoreImage +@used @_silgen_name("stbi_load_from_memory") -func stbi_load_from_memory(_ buffer: UnsafePointer, _ len: UInt64, _ x: UnsafeMutablePointer, _ y: UnsafeMutablePointer, _ comp: UnsafeMutablePointer, _ req_comp: Int32) -> UnsafeMutableRawPointer? { +public func stbi_load_from_memory(_ buffer: UnsafePointer, _ len: UInt64, _ x: UnsafeMutablePointer, _ y: UnsafeMutablePointer, _ comp: UnsafeMutablePointer, _ req_comp: Int32) -> UnsafeMutableRawPointer? { assert(req_comp == 3, "Only RGB format is supported") let data = Data(bytes: buffer, count: Int(len)) @@ -19,8 +20,9 @@ func stbi_load_from_memory(_ buffer: UnsafePointer, _ len: UInt64, _ x: return rgbBytes } +@used @_silgen_name("stbi_load") -func stbi_load(_ filename: UnsafePointer, _ x: UnsafeMutablePointer, _ y: UnsafeMutablePointer, _ comp: UnsafeMutablePointer, _ req_comp: Int32) -> UnsafeMutableRawPointer? { +public func stbi_load(_ filename: UnsafePointer, _ x: UnsafeMutablePointer, _ y: UnsafeMutablePointer, _ comp: UnsafeMutablePointer, _ req_comp: Int32) -> UnsafeMutableRawPointer? { assert(req_comp == 3, "Only RGB format is supported") guard let url = URL(string: String(cString: filename)), @@ -36,8 +38,9 @@ func stbi_load(_ filename: UnsafePointer, _ x: UnsafeMutablePointer Date: Sat, 6 Jun 2026 12:48:14 +0200 Subject: [PATCH 2/4] Update Sources/LocalLLMClientLlama/stb_image.swift Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- Sources/LocalLLMClientLlama/stb_image.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/LocalLLMClientLlama/stb_image.swift b/Sources/LocalLLMClientLlama/stb_image.swift index 3923b09..b5baf39 100644 --- a/Sources/LocalLLMClientLlama/stb_image.swift +++ b/Sources/LocalLLMClientLlama/stb_image.swift @@ -3,7 +3,7 @@ import Accelerate import CoreImage -@used +@_used @_silgen_name("stbi_load_from_memory") public func stbi_load_from_memory(_ buffer: UnsafePointer, _ len: UInt64, _ x: UnsafeMutablePointer, _ y: UnsafeMutablePointer, _ comp: UnsafeMutablePointer, _ req_comp: Int32) -> UnsafeMutableRawPointer? { assert(req_comp == 3, "Only RGB format is supported") From 111e309a049de30ce5a9122f50dfb7b6b13fbb4a Mon Sep 17 00:00:00 2001 From: DMYTRO BORYSOV <32671277+iborusik@users.noreply.github.com> Date: Sat, 6 Jun 2026 12:48:19 +0200 Subject: [PATCH 3/4] Update Sources/LocalLLMClientLlama/stb_image.swift Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- Sources/LocalLLMClientLlama/stb_image.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/LocalLLMClientLlama/stb_image.swift b/Sources/LocalLLMClientLlama/stb_image.swift index b5baf39..d5f08f0 100644 --- a/Sources/LocalLLMClientLlama/stb_image.swift +++ b/Sources/LocalLLMClientLlama/stb_image.swift @@ -20,7 +20,7 @@ public func stbi_load_from_memory(_ buffer: UnsafePointer, _ len: UInt64 return rgbBytes } -@used +@_used @_silgen_name("stbi_load") public func stbi_load(_ filename: UnsafePointer, _ x: UnsafeMutablePointer, _ y: UnsafeMutablePointer, _ comp: UnsafeMutablePointer, _ req_comp: Int32) -> UnsafeMutableRawPointer? { assert(req_comp == 3, "Only RGB format is supported") From 55587e383568fa94662265604c062a09b160f114 Mon Sep 17 00:00:00 2001 From: DMYTRO BORYSOV <32671277+iborusik@users.noreply.github.com> Date: Sat, 6 Jun 2026 12:48:25 +0200 Subject: [PATCH 4/4] Update Sources/LocalLLMClientLlama/stb_image.swift Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- Sources/LocalLLMClientLlama/stb_image.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/LocalLLMClientLlama/stb_image.swift b/Sources/LocalLLMClientLlama/stb_image.swift index d5f08f0..197f89f 100644 --- a/Sources/LocalLLMClientLlama/stb_image.swift +++ b/Sources/LocalLLMClientLlama/stb_image.swift @@ -38,7 +38,7 @@ public func stbi_load(_ filename: UnsafePointer, _ x: UnsafeMutablePointe return rgbBytes } -@used +@_used @_silgen_name("stbi_image_free") public func stbi_image_free(_ buffer: UnsafeMutableRawPointer) { buffer.assumingMemoryBound(to: UInt8.self).deallocate()