https://kotlinlang.org logo
Join SlackCommunities
Powered by
# ios
  • m

    Marc

    02/28/2025, 2:40 PM
    I am trying to call a Kotlin function that might throw an exception from Swift code. My goal is to retry this operation until it does not throw an exception anymore. To do that, I have added an
    @Throws
    annotation on the Kotlin side and now wrapped the Swift side with a
    Copy code
    do {
        try await operation()
    } catch let e as NSError {
        ...
    }
    block. Catching the exception kind of works as I can see logs from inside the catch block, but my app still crashes from the already caught and handled exception, saying that it is uncaught. Why is that happening?
    f
    • 2
    • 12
  • d

    darkmoon_uk

    03/02/2025, 11:10 AM
    Is there anything unconventional about how SKIE subscribes to Flows, when using the SwiftUI
    Observing
    View? Asking because I have a perplexing result... The view receives emissions if I start the Flow
    SharingStarted.Eagerly
    , but if I set it to
    WhileSubscribed
    it never starts... So is
    Observing
    subscribing or not 🤔
    t
    • 2
    • 1
  • e

    Enol SimĂłn

    03/02/2025, 3:24 PM
    Hi guys, I am implementing a map in my application with markers, which are SVG images, and I am having a performance problem. Most of the markers need to be shown in black and white, not colored. I have around 300 markers, where 280 more or less are like that. The problem is that in the first execution of the screen, the iPhone uses around 250 MB memory, it creates the markers, resize them and make them black and white. If I leave the screen and come back to it a couple of times, the memory usage raises to 2GB and the app crahses. If I don't make them black and white it does not happen and the memory stays in 250-300 mb. Is there any optimized way to fix this problem? A different way to make images black and white or release non used resources when I leave the screen? I explain more details of the implementation in the thread.
    f
    • 2
    • 3
  • m

    Meherdatta Chepuri

    03/05/2025, 7:47 PM
    thank you. But this does not talk about how to use the WhileSubscribed method?
    f
    • 2
    • 2
  • s

    Shageldi Alyyev

    03/06/2025, 6:30 AM
    Hello Everyone, I have compose multiplatform android/ios app. iOS app size 83 MB how I decrease this size? The cocoapods libraries are : [Maplibre, FirebaseCore, FirebaseMessaging], other one only kotlin common libraries
  • s

    Shageldi Alyyev

    03/06/2025, 6:34 AM
    Hello again my compose multiplatform ios app sometimes ui freezing when I call http request in the viewModel but same code is working fine in android. How I can fix this problem?
    k
    a
    • 3
    • 5
  • p

    Patryk Drozd

    03/10/2025, 11:33 AM
    Hey everyone, on my app in iosMain folder I would love to detect if user use wifi, cellular or ethernet. on iOS i can just create
    NWPathMonitor
    and listen to enum changes
    NWInterface.InterfaceType
    . But I can’t do that on KMP side? Anyone have any tips here?
  • s

    Saurabh Gupta

    03/13/2025, 5:22 PM
    Hello in our KMP project we are seeing extremely high build times. Of order of 30-40 minutes. We are trying to figure practices to reduce the build times. Part of the reason the build time is so high is because we are building out both x86 and arm flavors. Removing one of them only reduced build time by half. What other ideas we can implement to reduce build time? Is modularizing a good idea? I know iOS doesn’t support importing multiple frameworks built on kmp. But would just splitting into many modules help? Still package them into umbrella framework. Anyone has thoughts?
    f
    p
    • 3
    • 4
  • j

    John O'Reilly

    03/25/2025, 5:39 PM
    On Android we have some code that, if some request fails while say offline, kicks off Worker to run as soon as network connection available (and that will run whether app is in foreground or background). I know you can setup background tasks on iOS but doesn't see to offer quite same functionality (and very undeterministic when task will actually run!). Is anyone using any particular approach on iOS for this?
    d
    p
    +3
    • 6
    • 17
  • y

    Yuvaraj

    03/27/2025, 3:37 AM
    How can we access the AVPlayer FullScreen close button?
    x
    • 2
    • 1
  • d

    Dovydas

    03/27/2025, 4:02 PM
    I'm trying to use a variable font on a label in UIKitView, but the variations are not applying. What could I be doing wrong?
    • 1
    • 1
  • m

    Mikolaj

    03/28/2025, 9:30 AM
    Does anyone know how can I read the custom data sent in APN payload (push notification) while app is started from inactive state? Preferrably in kotlin. I've tried to catch it in
    AppDelegate
    (didFinishLaunchingWithOptions, didReceiveRemoteNotifications) and
    UNUserNotificationDelegate
    on kotlin side as well as in swift but with no luck. 🤔 This is a case of user opening app by tapping notification when app was closed completly (not in background)
    f
    • 2
    • 1
  • p

    Patryk Drozd

    04/01/2025, 12:17 PM
    Hey! I am working on integrating SwiftCode (CryptoKit) to my Kotlin Multiplatform Project but somehow I just can't do it. There is an example of
    SwiftChachaPoly
    on the internet but it's outdated. Here is my error and Gradle File. Error Message
    Copy code
    Exception in thread "main" java.lang.Error: /var/folders/4m/c90drcr50gsghb8p86fnn51r0000gp/T/17669576026474868801.m:1:10: fatal error: 'AppleBridge/AppleBridge-Swift.h' file not found
    
    Failed to generate cinterop for :shared:cinteropAppleBridgeIosArm64: Process 'command '/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java'' finished with non-zero exit value 1
    
    :shared:iosArm64Main: cinterop file: /Users/patrykdrozd/Programing/dms-agent/shared/build/libs/shared-iosArm64Cinterop-AppleBridgeMain-1.0.0.klib does not exist
    
    etc
    Gradle File
    Copy code
    listOf(
        iosArm64(),
        iosSimulatorArm64(),
    ).forEach {
        it.binaries.framework {
            baseName = "shared"
            isStatic = true
            binaryOption("bundleId", "shared")
        }
    
        val platform = when (it.name) {
            "iosArm64" -> "iphoneos"
            "iosSimulatorArm64" -> "iphonesimulator"
            else -> error("Unsupported target ${it.name}")
        }
    
        it.compilations.getByName("main") {
            cinterops.create("AppleBridge") {
                val interopTask = tasks[interopProcessingTaskName]
                interopTask.dependsOn(":AppleBridge:build${platform.replaceFirstChar(Char::titlecase)}")
                includeDirs.headerFilterOnly("$rootDir/AppleBridge/build/Release-$platform/include")
            }
        }
    }
    AppleBridge.def File
    Copy code
    language = Objective-C
    package = swift.appleBridge
    
    headers = AppleBridge/AppleBridge-Swift.h
    headerFilter = AppleBridge/*
    
    staticLibraries = libAppleBridge.a
    libraryPaths.ios_x64 = AppleBridge/build/Release-iphonesimulator
    libraryPaths.ios_simulator_arm64 = AppleBridge/build/Release-iphonesimulator
    libraryPaths.ios_arm64 = AppleBridge/build/Release-iphoneos
    
    linkerOpts = -L/usr/lib/swift
    linkerOpts.ios_x64 = -ios_simulator_version_min 13.0 -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/
    linkerOpts.ios_simulator_arm64 = -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/
    linkerOpts.ios_arm64 = -iphoneos_version_min 13.0 -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/
    Update I found that my Xcode project doesn't create folder with a header
    Debug-iphoneos/include/*-Bridging-Header.h
  • j

    John O'Reilly

    04/01/2025, 12:32 PM
    What do folks use for looking at application logs for an iOS app when not connected to the debugger? I've tried
    idevicesyslog
    for example but not showing the logs for some reason
    f
    • 2
    • 4
  • m

    Mikolaj

    04/03/2025, 12:34 PM
    I started getting those weird errors today
    Undefined symbols for architecture arm64
    . Anybody knows how to resolve this? I did not change anything and the build ran fine yesterday 🤔
    d
    • 2
    • 2
  • p

    Patryk Drozd

    04/07/2025, 2:28 PM
    Hey! Did anyone tried to use https://github.com/apple/swift-certificates inside KMP?
    f
    o
    b
    • 4
    • 12
  • p

    Patrick Cavanagh

    04/10/2025, 8:27 PM
    Has anyone managed to squeeze KMP into an App Clip? Seems like a tall task given the overheads of KMP and the 15MB limit if you go for the QR only approach.
    • 1
    • 2
  • d

    darkmoon_uk

    04/12/2025, 10:40 PM
    Long standing workflow issue for me with Kotlin Multiplatform for iOS... When I build for iOS device in Xcode, resulting
    shared
    Kotlin symbols are visible and navigable from Xcode âś… When building for simulator in Xcode, compilation result remains correct, but Kotlin symbols are unresolvable to the Xcode IDE đź™… Is there some search path or configuration that can be added to enable awareness of symbols from simulator build paths?
    r
    • 2
    • 1
  • p

    Patryk Drozd

    04/15/2025, 8:58 AM
    Hey, I am trying to use Swift
    thows
    with kotlin. Swift
    Copy code
    @objcMembers public class AESCryptoBridge: NSObject {
        public func test() throws {
            throw CryptoError.invalidData
        }
    }
    On Kotlin I have access to NSError but I have no idea how to use is. Is there any resource that will explain me how to work with?
    Copy code
    AESCryptoBridge().testAndReturnError("I have no idea how to use NSError Pointer here")
    I found this code but alloc is deprecated if I am correct
    Copy code
    val errorPointer: CPointer<ObjCObjectVar<NSError?>> = alloc<ObjCObjectVar<NSError?>>().ptr
    Update: I found the solution 🙂
    Copy code
    val error = memScoped {
        allocPointerTo<ObjCObjectVar<NSError?>>()
    }
    AESCryptoBridge().testAndReturnError(error.value)
    l
    • 2
    • 4
  • 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
    • 2
    • 3
  • 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?