diff --git a/README.md b/README.md index 9b6f2a8..8679fa5 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ Platform-specific application home and cache directories for KMP. | Platform | Cache Directory | Data Directory | |-----------------------|--------------------------------------------|--------------------------------------------| | Android | `context.cacheDir` | `ApplicationInfo.dataDir` | -| IOS/IpadOs/WatchOs | `NSCachesDirectory` | `NSHomeDirectory` | +| IOS/IpadOs/WatchOs | `NSCachesDirectory` | `NSApplicationSupportDirectory` | | Mac (native/jvm/node) | `~/Library/Caches/` | `~/Library/Application Support/` | | Windows (jvm/node) | `C:\Users\\AppData/Caches/` | `C:\Users\\AppData/>` | | Linux (jvm/node) | `~/.cache/` | `~/local/share/` | @@ -58,7 +58,7 @@ val packageName = "example.com.app" val dataDirectory = appDataDirectory(packageName) ``` -This will return `ApplicationInfo.dataDir` on android, `NSHomeDirectory` on IOS and equivalent platform specific data +This will return `ApplicationInfo.dataDir` on android, `NSApplicationSupportDirectory` on IOS and equivalent platform specific data directory on other platforms. #### App cache directory diff --git a/multiplatform-paths/build.gradle.kts b/multiplatform-paths/build.gradle.kts index 6ddb465..1acaa52 100644 --- a/multiplatform-paths/build.gradle.kts +++ b/multiplatform-paths/build.gradle.kts @@ -95,7 +95,7 @@ mavenPublishing { pom { name.set("Multiplatform Paths") description.set( - "Get platform specific app data and cache directory(equivalent to ApplicationInfo.dataDir or NSHomeDirectory) in Kotlin Multiplatform application", + "Get platform specific app data and cache directory(equivalent to ApplicationInfo.dataDir or NSApplicationSupportDirectory) in Kotlin Multiplatform application", ) } } diff --git a/multiplatform-paths/src/darwinMain/kotlin/me/sujanpoudel/utils/paths/directories.darwin.kt b/multiplatform-paths/src/darwinMain/kotlin/me/sujanpoudel/utils/paths/directories.darwin.kt index 5682a76..b6fc21a 100644 --- a/multiplatform-paths/src/darwinMain/kotlin/me/sujanpoudel/utils/paths/directories.darwin.kt +++ b/multiplatform-paths/src/darwinMain/kotlin/me/sujanpoudel/utils/paths/directories.darwin.kt @@ -23,17 +23,13 @@ import me.sujanpoudel.utils.platformIdentifier.Platform import me.sujanpoudel.utils.platformIdentifier.platform import platform.Foundation.NSApplicationSupportDirectory import platform.Foundation.NSCachesDirectory -import platform.Foundation.NSHomeDirectory import platform.Foundation.NSSearchPathForDirectoriesInDomains import platform.Foundation.NSUserDomainMask -actual fun dataDirectory(appId: String): Path = if (platform() is Platform.OS.MacOs) { +actual fun dataDirectory(appId: String): Path = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, true) .firstOrNull()?.toString()?.toPath() ?.let { it / appId } ?: error("Unable to get 'NSApplicationSupportDirectory'") -} else { - NSHomeDirectory().toPath() -} actual fun cacheDirectory(appId: String): Path { val cachesDirectory = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, true)