Hi guys, Little question for iOS 18 to open setti...
# compose-ios
s
Hi guys, Little question for iOS 18 to open setting we need to use https://developer.apple.com/documentation/uikit/uiapplication/1648685-open
UIApplication.sharedApplication().open(_:options:completionHandler:)
instead of
UIApplication.sharedApplication().openURL(nsUrl)
Does anyone encounter that issue? Not sure to understand how Platform is updated… Quite a blocking point
d
Is this related to Compose?
s
I guess so @Dmitry Stakhov, I am using in it in Platform.ios.kt
UIApplication.sharedApplication().openURL(nsUrl)
in a kotlin file, but it is not compatible with ios 18. You know for the bridge with actual/expect.
Copy code
internal actual fun navigateToDeviceFeatures() {
val nsUrl = NSURL.URLWithString(UIApplicationOpenSettingsURLString)

val success = UIApplication.sharedApplication().openURL(nsUrl)
    if (!success) {
        println("Failed to open URL: $nsUrl")
    }
}
This is related to compose, my question is who is responsible of that
import Platform.UIApplication
UIApplication.sharedApplication().open(_optionscompletionHandler:) can’t be found
d
Could you please mention the Compose API you try to use?
UIApplication
is a native component and a part of UIKit
s
Yes but the UIApplication from the import
Platform.UIApplication
is a “binding` from Kotlin right? .open() is missing while openUrl() is available
d
> import
Platform.UIApplication
is a “binding` from Kotlin right No, It's built from ObjectiveC using Cinterop tool that supports calling ObjectiveC code from Kotlin. So basically Kotlin just provides you the API that Apple has added to their iOS SDK
s
Thanks a lot for this precious information @Dmitry Stakhov Is there a way to re-run that Cinterop tool to have the API updated from iOS SDK?
d
I guess just sync the project. Do you have the XCode 16 installed and xcode build tools set up correctly? To confirm you have the correct Xcode setup you can run the
xcodeVersion
Gradle task from your KMP project to check Kotlin has detected to Xcode build tools with the right version. If everything is ok run
commonizeNativeDistribution
Gradle task to regenerate Kotlin functions to call iOS SDK. Also for similar questions please reach to the #C3PQML5NU or #C3SGXARS6 channel
👍 1
s
Yes I have xCode 16 and trying on the newest iphone got some imcompatibilty, I will search about that
commonizeNativeDistribution
that i dont really have in Gradle. Thanks for the advices
h
I also use same as u before ios18. so what should we do? need if else to check up if ok or not?
v
The function name is not the same in objC and swift. The swift is named open() but you should use the openURL() function. The change you must do is add a completionHandler parameter that is now required in ios18
👀 1
s
Oh thanks @Vaizin Nikita I will check it out! And let you know… didn’t know function name are different between objectiveC and Swift…
Yes that works, thanks a lot @Vaizin Nikita