diff --git a/samples/sample/KermitSampleIOS/KermitSampleIOS/ContentView.swift b/samples/sample/KermitSampleIOS/KermitSampleIOS/ContentView.swift index 56cdb73e..7ce2b0df 100644 --- a/samples/sample/KermitSampleIOS/KermitSampleIOS/ContentView.swift +++ b/samples/sample/KermitSampleIOS/KermitSampleIOS/ContentView.swift @@ -15,14 +15,14 @@ import shared struct ContentView: View { - let common: SampleMobile + let common: SampleIOS init() { let filePath = NSHomeDirectory() + "/Documents/" let fileName = "KermitSampleLogs" ContentView.createLoggingFile(withName: fileName, atPath: filePath) - self.common = SampleMobile(filePathString: filePath, logFileName: fileName) + self.common = SampleIOS(filePathString: filePath, logFileName: fileName) } private static func createLoggingFile(withName name:String, atPath filePath: String){ diff --git a/samples/sample/app/src/main/java/co/touchlab/KermitSample/FirstFragment.kt b/samples/sample/app/src/main/java/co/touchlab/KermitSample/FirstFragment.kt index 116e8c6a..362a6cc8 100644 --- a/samples/sample/app/src/main/java/co/touchlab/KermitSample/FirstFragment.kt +++ b/samples/sample/app/src/main/java/co/touchlab/KermitSample/FirstFragment.kt @@ -15,7 +15,7 @@ import android.view.View import androidx.fragment.app.Fragment import co.touchlab.KermitSample.databinding.FragmentFirstBinding import co.touchlab.kermit.Logger -import co.touchlab.kermitsample.SampleMobile +import co.touchlab.kermitsample.SampleAndroid /** * A simple [Fragment] subclass as the default destination in the navigation. @@ -25,7 +25,7 @@ class FirstFragment : Fragment(R.layout.fragment_first) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) Logger.withTag("FirstFragment").v("First fragment loaded") - val sample = SampleMobile(context?.filesDir?.path ?: "") + val sample = SampleAndroid(context?.filesDir?.path ?: "") val binding = FragmentFirstBinding.bind(view) binding.btnClickCount.setOnClickListener { sample.onClickI() } binding.btnException.setOnClickListener { sample.logException() } diff --git a/samples/sample/shared/build.gradle.kts b/samples/sample/shared/build.gradle.kts index 76957897..9d3c7673 100644 --- a/samples/sample/shared/build.gradle.kts +++ b/samples/sample/shared/build.gradle.kts @@ -59,24 +59,13 @@ kotlin { implementation("co.touchlab:kermit-test:${KERMIT_VERSION}") } - val mobileMain by creating { - dependsOn(commonMain.get()) - dependencies { - implementation("co.touchlab:kermit-io:${KERMIT_VERSION}") - } + androidMain.dependencies { + implementation("co.touchlab:kermit-io:${KERMIT_VERSION}") } - androidMain { - dependsOn(mobileMain) - } - iosMain { - dependsOn(mobileMain) - iosX64Main.get().dependsOn(this) - iosArm64Main.get().dependsOn(this) - iosSimulatorArm64Main.get().dependsOn(this) - dependencies { - // Only if you want to talk to Kermit from Swift - api("co.touchlab:kermit-simple:${KERMIT_VERSION}") - } + iosMain.dependencies { + // Only if you want to talk to Kermit from Swift + api("co.touchlab:kermit-simple:${KERMIT_VERSION}") + implementation("co.touchlab:kermit-io:${KERMIT_VERSION}") } } cocoapods { diff --git a/samples/sample/shared/src/androidMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt b/samples/sample/shared/src/androidMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt new file mode 100644 index 00000000..5df98418 --- /dev/null +++ b/samples/sample/shared/src/androidMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 Touchlab + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + */ + +package co.touchlab.kermitsample + +import co.touchlab.kermit.Logger +import co.touchlab.kermit.io.RollingFileLogWriter +import co.touchlab.kermit.io.RollingFileLogWriterConfig +import kotlinx.io.files.Path + +class SampleAndroid(filePathString: String, logFileName: String = "KermitSampleLogs") : SampleCommon() { + init { + Logger.addLogWriter( + RollingFileLogWriter( + config = RollingFileLogWriterConfig( + logFileName = logFileName, + logFilePath = Path(filePathString), + ) + ) + ) + } +} \ No newline at end of file diff --git a/samples/sample/shared/src/mobileMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt b/samples/sample/shared/src/iosMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt similarity index 91% rename from samples/sample/shared/src/mobileMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt rename to samples/sample/shared/src/iosMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt index 297bfd7a..f864d853 100644 --- a/samples/sample/shared/src/mobileMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt +++ b/samples/sample/shared/src/iosMain/kotlin/co/touchlab/kermitsample/SampleMobile.kt @@ -15,7 +15,7 @@ import co.touchlab.kermit.io.RollingFileLogWriter import co.touchlab.kermit.io.RollingFileLogWriterConfig import kotlinx.io.files.Path -class SampleMobile(filePathString: String, logFileName: String = "KermitSampleLogs") : SampleCommon() { +class SampleIOS(filePathString: String, logFileName: String = "KermitSampleLogs") : SampleCommon() { init { Logger.addLogWriter( RollingFileLogWriter(