Skip to content

Commit 4769b5b

Browse files
author
Onion
committed
fix: fix dylib copy in MacOS
1 parent 84a7374 commit 4769b5b

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

CHANGELOG.md

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

55
本项目遵循 [语义化版本](https://semver.org/spec/v2.0.0.html)
66

7+
## v1.3.1
8+
9+
- fix dylib copy in MacOS
10+
11+
712
## v1.3.0
813

914
- jvmArgs change

composeApp/src/jvmMain/kotlin/org/onion/diffusion/utils/NativeLibraryLoader.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,11 @@ object NativeLibraryLoader {
5151
val tempLibFile: File
5252
val tempLibLibraryFile: File
5353
try {
54-
// Create a temporary file with a more descriptive name if possible
55-
tempLibFile = File(libFileName)
54+
// Create a temporary directory to hold the library files
55+
val tempDir = java.nio.file.Files.createTempDirectory("native_libs_${baseName}_").toFile()
56+
tempDir.deleteOnExit() // Clean up directory on exit
57+
58+
tempLibFile = File(tempDir, libFileName)
5659
tempLibFile.deleteOnExit() // Important for cleanup
5760
println("tempFile Name ${tempLibFile.absolutePath}")
5861
FileOutputStream(tempLibFile).use { outputStream ->
@@ -61,7 +64,7 @@ object NativeLibraryLoader {
6164
}
6265
}
6366
if(libFileLibraryStream != null){
64-
tempLibLibraryFile = File("$libFileName.a")
67+
tempLibLibraryFile = File(tempDir, "$libFileName.a")
6568
tempLibLibraryFile.deleteOnExit()
6669
FileOutputStream(tempLibLibraryFile).use { outputStream ->
6770
libFileLibraryStream.use { input ->

0 commit comments

Comments
 (0)