https://kotlinlang.org logo
Join Slack
Powered by
# ios
  • d

    Dovydas

    04/16/2025, 5:17 PM
    Hi all, what's the minimal boilerplate code way to define an actual implementation of an expect class straight in swift?
    f
    • 2
    • 2
  • f

    François

    04/19/2025, 8:29 AM
    Hello, a big tip about the completion issue with Xcode. If you’re using custom Xcode configuration (more than Debug/Release), it’s breaking SOURCE_KIT. For fixing this issue, add next to your Compile Kotlin Framework - Build phase. •
    cd "${SRCROOT}/../shared/build/xcode-frameworks/"
    (or any other path to the shared framework •
    ln -Fs "${CONFIGURATION}" "Debug"
    A Debug directory is mandatory for SOURCE_KIT to work!
    🚀 3
  • d

    Dovydas

    04/20/2025, 3:28 PM
    If I have a Kotlin interface with functions or variables that have a body and which I don't want to override, when implementing it in Swift, it requires me to still override everything.
    f
    • 2
    • 4
  • c

    chandilsachin

    04/22/2025, 12:19 PM
    It could be a naive question. Is there a support for adding the breakpoint in kotlin code and debug in xcode? If not then how others are debugging the code? What other solutions are there for the same?
    👍 1
    m
    • 2
    • 3
  • m

    Marc

    04/22/2025, 2:33 PM
    Is there a way to properly export a UByteArray type in an interface to Swift? Unlike a normal ByteArray it just turns into Any instead of KotlinByteArray.
  • m

    Max

    04/22/2025, 6:27 PM
    👀 KMP Classes not visible in Swift by default 👀 Sometimes I face the issue that classes defined in KMP shared code are not visible in Swift. I work around this issue by adding a “fake usage” to the
    MainViewController.kt
    class like below. Afterwards I can access
    IOSPlatformFile
    in Swift code.
    Copy code
    fun MainViewController() = ComposeUIViewController { App() }
    
    // so swift code can access this
    val platformFile: IOSPlatformFile = IOSPlatformFile("")
    Could someone clarify what I’m doing wrong in these cases? Are only classes from the main module visible to Swift by default?
    ✅ 1
    f
    • 2
    • 4
  • h

    Hasan Nagizade

    05/02/2025, 6:50 AM
    I don't know if it's offtopic or not but I need iOS Device Support files for 18.5 (22F5053f). Would be grateful for any help
    m
    • 2
    • 2
  • g

    GNKumar

    05/02/2025, 1:40 PM
    Hi , Team I am working on BLE iOS application. While reading the data from BLE device continuously, I am getting below crash Message from debugger: Terminated due to signal 9 Note: app running in background. Any suggestions on how to resolve it? Thanks, GNKumar.
  • m

    Mikolaj

    05/06/2025, 1:40 PM
    Is there anything I can do to make
    embedAndSign
    run faster (besides buy new computer)? I'm not using cocoapods nor SPM, only kotlin (and minimum swift boilerplate) yet full ios build still takes 20-30 minutes (macbook M3 16GB ram) *embedAndSign takes >50% of that time
    k
    m
    • 3
    • 5
  • f

    Farhazul Mullick

    05/07/2025, 9:24 AM
    Hey, I am using
    kotlin native cocoapods
    . I have few questions. 1. Why kotlin native cocoapods plugin automatically creates podspec file upon sync. 2. If i use some cocoapods dependency and like Alamofire. I can define in gradle inside cocoapods block. Upon gradle sync podInstall task is ran by gradle. Then kotlin files of those pods are generated from cocoapods package. This later compiled with the final fat-framework. We can use this framework in any ios app. If so why we need to create a pod file in iosApp and run pod install there as well?
    f
    • 2
    • 4
  • a

    abraham

    05/09/2025, 2:43 PM
    Hey, sorry if this is a stupid question as I don't know much about iOS development. When I use "jump to definition" in XCode on a (KMP) method or class from code, it will jump to that (basically) unreadable generated header file. However if I do the same on the module import it does show that header in a more human readable format, is there a flag or setting I forgot that parses all those
    swift_name
    attributes?
    m
    • 2
    • 3
  • f

    François

    05/13/2025, 10:37 AM
    Hi everyone, Your SwiftUI Preview are not working well or slow because of infinite Gradle build Framework task? The solution : Check for change inside your shared Kotlin source to avoid useless build! Working only if you’re building a dynamic framework
    Copy code
    CUR="${SRCROOT}/../shared/build/list_of_files.txt"
    OLD="${SRCROOT}/../shared/build/old_list_of_files.txt"
    touch $OLD
    CHANGES="${SRCROOT}/../shared/build/list_of_changes.txt"
    
    ls -lRT "${SRCROOT}/../shared/src/" > $CUR
    diff $OLD $CUR > $CHANGES
    
    if [ ! -s "${CHANGES}" ]; then
      echo "No change in shared source"
      exit 0
    fi
    
    
    if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then
     echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\""
     exit 0
    fi
    cd "$SRCROOT/.."
    ./gradlew :shared:embedAndSignAppleFrameworkForXcode
    
    # set the current change as old after the build is OK
    mv $CUR $OLD
    😮 2
    👍 2
    • 1
    • 1
  • j

    jQrgen

    05/16/2025, 11:01 AM
    How do we know how much stuff we can run in background? iOS sandbox keeps killing our app in background on large network loads for syncing and verification blockchain headers using cryptographic signature verification
    f
    • 2
    • 4
  • f

    F

    05/21/2025, 5:29 PM
    Are there any examples of disabling back on a specific screen using Circuit? i want to disabling the swiping that triggers back on a specifiek screen based on some value.
  • c

    chrisjenx

    05/24/2025, 6:23 PM
    Anyone know how to fix the Dropdown read only selectable text regression on iOS (Regressed 1.7 > 1.8)
    • 1
    • 2
  • v

    Vivek Gupta

    05/27/2025, 10:33 AM
    Can anyone guide/share a demo setup/steps for adding KMM support on existing iOS project ?
    a
    t
    • 3
    • 2
  • r

    Raphael TEYSSANDIER

    05/29/2025, 10:19 PM
    I'm trying to publish a lib that use Room 2.7.1 to maven central, but will using
    publishAndReleaseToMavenCentral
    on github actions. But I get an error for iOS:
    Copy code
    > Task :xxx:compileKotlinIosSimulatorArm64
    e: file:///Users/runner/work/xxx/xxx/xxx/build/generated/ksp/metadata/commonMain/kotlin/io/dot/lorraine/db/XXXConstructor.kt:5:24 'actual object XXXConstructor : RoomDatabaseConstructor<XXXDB>' has no corresponding expected declaration
    e: file:///Users/runner/work/xxx/xxx/xxx/build/generated/ksp/metadata/commonMain/kotlin/io/dot/xxx/db/XXXConstructor.kt:5:24 XXXConstructor: expect and corresponding actual are declared in the same module.
    > Task :xxx:compileCommonMainKotlinMetadata FAILED
    e: file:///Users/runner/work/xxx/xxx/xxx/build/generated/ksp/metadata/commonMain/kotlin/io/dot/xxx/db/XXXConstructor.kt:6:23 'actual fun initialize(): XXXDB' has no corresponding expected declaration
    e: file:///Users/runner/work/xxx/xxx/xx/src/commonMain/kotlin/io/dot/xxx/db/XXXConstructor.kt:6:24 XXXConstructor: expect and corresponding actual are declared in the same module.
    Any idea how to fix it ?
    p
    • 2
    • 5
  • m

    Muaz KADAN

    06/01/2025, 8:26 AM
    Hi, if I want to use compose resources from a KMP module in iOS Do we have something that does what this function does out of the box?
    Copy code
    fun StringResource.localized(): String {
        return runBlocking { getString(this@localized) }
    }
    k
    d
    d
    • 4
    • 5
  • a

    Anant Kumar Gupta

    06/07/2025, 4:21 AM
    Hello guyz, Has anyone encountered this? Is it something to worry about, or is there a better way to safely handle
    CGImage
    in Kotlin/Native? Warning - Cannot access class 'cnames. structs. CGImage' in the expression type. While it may work, this case indicates a configuration mistake and can lead to avoidable compilation errors, so it may be forbidden soon. Check your module classpath for missing or conflicting dependencies.
    Copy code
    fun generateVideoThumbnailIOS(
        uri: String
    ): ImageBitmap? = memScoped {
        val nsUrl = NSURL.Companion.fileURLWithPath(uri.removePrefix("file://"))
        val asset = AVURLAsset.URLAssetWithURL(nsUrl, null)
        val generator = AVAssetImageGenerator(asset)
        generator.appliesPreferredTrackTransform = true
        val requestedTime = CMTimeMake(1, 1).useContents { readValue() }
        val actualTime: CMTime = alloc<CMTime>()
        val errorPtr = alloc<ObjCObjectVar<NSError?>>()
        val cgImage = generator.copyCGImageAtTime(
            requestedTime = requestedTime,
            actualTime = actualTime.ptr,
            error = errorPtr.ptr
        ) ?: run {
            println("Error: ${errorPtr.value?.localizedDescription}")
            return@memScoped null
        }
    
        val uiImage = UIImage.imageWithCGImage(cgImage)
        val nsData = uiImage.pngRepresentation() ?: return@memScoped null
        val length = nsData.length.toInt()
        val bytePtr = nsData.bytes?.reinterpret<ByteVar>() ?: return@memScoped null
        val byteArray = bytePtr.readBytes(length)
        val finalThumbnail = Image.makeFromEncoded(byteArray).toComposeImageBitmap()
        return@memScoped finalThumbnail
    }
    👀 1
    f
    • 2
    • 1
  • j

    Jasmin

    07/04/2025, 8:47 AM
    Hello 👋 I’m building an KMP Lib. I have assets under
    commonMain/resources/files/frontend
    . How do I need to configure Gradle to bundle these assets in the XCFramework and access them via
    NSBundle
    ? I know it must be possible somehow, because of the composeResources, which are getting correctly included. Here is my current access code:
    val basePath = NSBundle.mainBundle.resourcePath + "/files/frontend/"
    Every help is appreciated 🙂
    f
    • 2
    • 2
  • m

    Max

    07/05/2025, 11:18 AM
    ⚡⚡⚡ ️Question about performance on iOS Given I use purely KMP (no CMP) on iOS. Ui is in SwiftUi, then from my understanding all the Kotlin codes gets compiled into native binaries, as does Objective C. 1. there should be no performance impact if my business/data layer are in Kotlin or Objective C, right? 2. there should also be no battery impact kmp vs objective c, Or am i missing something? People who already use KMP in production: how do you rate performance?
    ✅ 1
    a
    j
    k
    • 4
    • 7
  • m

    Mario

    07/08/2025, 8:09 AM
    Hi all - I think it's impossible to use
    AVCaptureVideoDataOutputSampleBufferDelegateProtocol
    because both its method definitions are the same, just with different names:
    Copy code
    public expect interface AVCaptureVideoDataOutputSampleBufferDelegateProtocol : platform.darwin.NSObjectProtocol {
        @kotlin.commonizer.ObjCCallable @kotlinx.cinterop.ObjCMethod public open expect fun captureOutput(output: platform.AVFoundation.AVCaptureOutput, didOutputSampleBuffer: kotlinx.cinterop.CPointer<cnames.structs.opaqueCMSampleBuffer>? /* from: platform.CoreMedia.CMSampleBufferRef? */, fromConnection: platform.AVFoundation.AVCaptureConnection): kotlin.Unit { /* compiled code */ }
    
        @kotlin.commonizer.ObjCCallable @kotlinx.cinterop.ObjCMethod public open expect fun captureOutput(output: platform.AVFoundation.AVCaptureOutput, didDropSampleBuffer: kotlinx.cinterop.CPointer<cnames.structs.opaqueCMSampleBuffer>? /* from: platform.CoreMedia.CMSampleBufferRef? */, fromConnection: platform.AVFoundation.AVCaptureConnection): kotlin.Unit { /* compiled code */ }
    }
    When I try to implement it, I get the following error:
    Copy code
    object : NSObject(), AVCaptureVideoDataOutputSampleBufferDelegateProtocol {
            override fun captureOutput(
                output: AVCaptureOutput,
                didOutputSampleBuffer: CMSampleBufferRef?,
                fromConnection: AVCaptureConnection
            ) {
                super.captureOutput(output, didOutputSampleBuffer, fromConnection)
            }
        }
    Copy code
    The corresponding parameter in the supertype 'AVCaptureVideoDataOutputSampleBufferDelegateProtocol' is named 'didDropSampleBuffer'. This may cause problems when calling this function with named arguments.
    d
    • 2
    • 2
  • a

    Anmol Verma

    07/17/2025, 5:21 PM
    https://kotlinlang.slack.com/archives/C3PQML5NU/p1752770413738959 Hi Folks, need some help with this error
  • g

    GNKumar

    07/22/2025, 4:11 AM
    Hi, Devs Does anyone have any idea , how to unzip the file using Swift without using any CocoaPods?
    a
    • 2
    • 2
  • k

    Kashismails

    07/29/2025, 8:52 AM
    🧵HAs anyone updated to macOs 26? getting this when building with xcode 26
    j
    • 2
    • 9
  • x

    xxfast

    08/06/2025, 1:19 AM
    Has anyone seen this error before? Not sure why im started seeing this all the sudden - all i did was to restart xcode
    Copy code
    Execution failed for task ':connect:compileKotlinIosArm64'.
    > Error while evaluating property 'kotlinNativeProvider$kotlin_gradle_plugin_common.kotlinNativeBundleVersion$kotlin_gradle_plugin_common' of task ':connect:compileKotlinIosArm64'.
    Showing All Messages
       > java.nio.file.FileAlreadyExistsException: /Users/User/.konan/kotlin-native-prebuilt-macos-x86_64-2.2.0/tools/konan_lldb.py
    r
    • 2
    • 3
  • f

    Fernando

    08/11/2025, 6:18 PM
    Hi! Quick question: I want to move my
    iosApp
    into an
    apps
    directory. I was able to move everything else but the iOS project, for some reason, it won't work. I've tried moving it with the Terminal, but it will not allow me to run the iOS project from the IDE (trough the Kotlin Multiplatform Project) Does anybody knows how can I move it while being able to run it from the IDE?
    p
    p
    • 3
    • 4
  • e

    Excellence kawej

    08/13/2025, 10:48 AM
    Hi everyone...
  • e

    Excellence kawej

    08/13/2025, 10:55 AM
    I'm getting this error while trying to implement Google authentication with Firebase:
    /Users/ctrltech/StudioProjects/Tmaterials/iosApp/iosApp/FirebaseBridge.swift:37:69 Trailing closure passed to parameter of type 'String' that does not accept a closure
    Here is my implementation:
    Copy code
    import Foundation
    import FirebaseCore
    import Firebase
    import FirebaseAuth
    import GoogleSignInSwift
    import GoogleSignIn
    
    @objc class FirebaseBridge: NSObject {
        @objc static func configureFirebase() {
            if <http://FirebaseApp.app|FirebaseApp.app>() == nil {
                FirebaseApp.configure()
            }
        }
    
        @objc static func isUserSignedIn() -> Bool {
            return Auth.auth().currentUser != nil
        }
    
        @objc static func signOut() {
            try? Auth.auth().signOut()
        }
    
        @objc static func signInWithGoogle(presenting: UIViewController, completion: @escaping (FirebaseUserWrapper?, Error?) -> Void) {
            guard let clientID = <http://FirebaseApp.app|FirebaseApp.app>()?.options.clientID else {
                completion(nil, NSError(domain: "NoClientID", code: 0))
                return
            }
    
            let config = GIDConfiguration(clientID: clientID)
            GIDSignIn.sharedInstance.signIn(withPresenting: presenting) { result in //error happens here
                switch result {
                case .success(let signInResult):
                    let user = result.user
                    guard let idToken = user.idToken?.tokenString else {
                        completion(nil, NSError(domain: "MissingIdToken", code: 1))
                        return
                    }
                    let accessToken = user.accessToken.tokenString
    
                    guard let idToken = idToken else {
                        completion(nil, NSError(domain: "MissingIdToken", code: 1))
                        return
                    }
    
                    let credential = GoogleAuthProvider.credential(withIDToken: idToken, accessToken: accessToken)
    
                    Auth.auth().signIn(with: credential) { authResult, error in
                        if let error = error {
                            completion(nil, NSError(domain: error.localizedDescription, code: 1))
                        } else if let firebaseUser = authResult?.user {
                            completion(FirebaseUserWrapper(user: firebaseUser), nil)
                        } else {
                            completion(authResult?.user.uid, nil)
                        }
                    }
                case .failure(let error):
                    if let error = error {
                        completion(nil, error)
                        return
                    }
    
                    guard let result = result else {
                        completion(nil, NSError(domain: "GoogleSignInError", code: 1))
                        return
                    }
                }
            }
        }
    }
    
    @objc class FirebaseUserWrapper: NSObject {
        let uid: String
        let email: String?
        let displayName: String?
        
        init(user: User) {
            self.uid = user.uid
            self.email = user.email
            self.displayName = user.displayName
        }
    }
    a
    • 2
    • 2
  • m

    Mirzamehdi

    08/28/2025, 5:38 PM
    https://github.com/GitLiveApp/firebase-kotlin-sdk/issues/750#issuecomment-3197274509 is iosX64 deprecated already?
    a
    r
    • 3
    • 5