diff --git a/build.gradle.kts b/build.gradle.kts index a43c8ec..94f7ad2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -51,6 +51,9 @@ kotlin { } } } + iosX64() + iosArm64() + iosSimulatorArm64() @OptIn(org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi::class) applyHierarchyTemplate { @@ -66,6 +69,11 @@ kotlin { withLinuxX64() withLinuxArm64() } + group("ios") { + withIosX64() + withIosArm64() + withIosSimulatorArm64() + } } } @@ -181,6 +189,14 @@ kotlin { implementation("androidx.test:runner:1.6.2") } } + + // ios + val iosMain by getting { + dependsOn(commonMain) + } + val iosTest by getting { + dependsOn(commonTest) + } } } diff --git a/src/iosMain/kotlin/ca/gosyer/appdirs/AppDirs.kt b/src/iosMain/kotlin/ca/gosyer/appdirs/AppDirs.kt new file mode 100644 index 0000000..073dfb0 --- /dev/null +++ b/src/iosMain/kotlin/ca/gosyer/appdirs/AppDirs.kt @@ -0,0 +1,32 @@ +package ca.gosyer.appdirs + +actual fun AppDirs(config: AppDirsConfig.() -> Unit): AppDirs { + val config = AppDirsConfig().apply(config) + return TODO() +} + +@Deprecated("Use AppDirs DSL instead.") +actual fun AppDirs( + appName: String?, + appAuthor: String?, + vararg extra: String, +): AppDirs { + return AppDirs { + this.appName = appName + this.appAuthor = appAuthor + this.extras = extra + } +} + +@Deprecated("Use AppDirs DSL instead.") +fun AppDirs( + appName: String?, + appAuthor: String? = null, + extra: List = emptyList(), +): AppDirs { + return AppDirs { + this.appName = appName + this.appAuthor = appAuthor + this.extras = extra.toTypedArray() + } +} \ No newline at end of file diff --git a/src/iosMain/kotlin/ca/gosyer/appdirs/impl/IosAppDirs.kt b/src/iosMain/kotlin/ca/gosyer/appdirs/impl/IosAppDirs.kt new file mode 100644 index 0000000..901c592 --- /dev/null +++ b/src/iosMain/kotlin/ca/gosyer/appdirs/impl/IosAppDirs.kt @@ -0,0 +1,39 @@ +package ca.gosyer.appdirs.impl + +import ca.gosyer.appdirs.AppDirs +import ca.gosyer.appdirs.AppDirsConfig +import ca.gosyer.appdirs.impl.pathSeparator + +class IosAppDirs( + appDirsConfig: AppDirsConfig, +): AppDirs { + private val extras = appDirsConfig.extras.joinToString(pathSeparator()) + + override fun getUserDataDir(roaming: Boolean): String { + return TODO() + } + + override fun getUserCacheDir(): String { + return TODO() + } + + override fun getUserConfigDir(roaming: Boolean): String { + return TODO() + } + + override fun getUserLogDir(): String { + return TODO() + } + + override fun getSiteDataDir(multiPath: Boolean): String { + return TODO() + } + + override fun getSiteConfigDir(multiPath: Boolean): String { + return TODO() + } + + override fun getSharedDir(): String { + return TODO() + } +} \ No newline at end of file diff --git a/src/iosMain/kotlin/ca/gosyer/appdirs/impl/IosUtil.kt b/src/iosMain/kotlin/ca/gosyer/appdirs/impl/IosUtil.kt new file mode 100644 index 0000000..5be4538 --- /dev/null +++ b/src/iosMain/kotlin/ca/gosyer/appdirs/impl/IosUtil.kt @@ -0,0 +1,18 @@ +package ca.gosyer.appdirs.impl + +import kotlinx.cinterop.ExperimentalForeignApi +import kotlinx.cinterop.memScoped +import kotlinx.cinterop.pointed +import kotlinx.cinterop.toKString +import platform.posix.getenv +import platform.posix.getpwuid +import platform.posix.getuid + +@OptIn(ExperimentalForeignApi::class) +internal actual fun home(): String { + throw NotImplementedError("home() not implemented on iOS") +} + +internal actual fun fileSeparator() : String = "/" + +internal actual fun pathSeparator() : String = ":" \ No newline at end of file