Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swift _kotlin interop update #11

Merged
merged 1 commit into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
13 changes: 8 additions & 5 deletions multiplatformContact/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ kotlin {
iosSimulatorArm64()
)

// iosTargets.forEach { target ->
// target.compilations["main"].cinterops {
// create("ContactsHelper")
// }
// }
iosTargets.forEach { target ->
target.compilations["main"].cinterops {
create("ContactsHelper") {
defFile(project.file("src/iosMain/cinterop/ContactsHelper.def"))
packageName("io.github.lilytreasure")
}
}
}

cocoapods {
version = "1.0.0"
Expand Down
5 changes: 5 additions & 0 deletions multiplatformContact/src/iosMain/cinterop/ContactsHelper.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package = io.github.lilytreasure
language = Objective-C
headers = ContactsHelper.h
compilerOpts = -target arm64-apple-ios14.0
linkerOpts = -framework Foundation
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package multiContacts

import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import io.github.lilytreasure.ContactsHelper
import kotlinx.cinterop.ExperimentalForeignApi
import platform.Contacts.CNContact
import platform.ContactsUI.CNContactPickerDelegateProtocol
Expand All @@ -18,14 +19,15 @@ import platform.darwin.NSObject
typealias ContactPickedCallback = (String) -> Unit


@OptIn(ExperimentalForeignApi::class)
@Composable
actual fun pickMultiplatformContacts(
countryISOCode: String,
onResult: ContactPickedCallback
): Launcher {
//Contacts helper
// val contacts=ContactsHelper()
// contacts.loadContacts()
val contacts=ContactsHelper()
contacts.loadContacts()
val launcherCustom = remember {
Launcher(onLaunch = {
val picker = CNContactPickerViewController()
Expand Down