esdrasdl
10/23/2025, 7:42 PMiosMain source set of our KMP module. Specifically, we are trying to use NSURLCredential. I'm relatively new to KMP and might be making a mistake.
This error is easy to reproduce. I downloaded the sample project from this repository and added a new class in `shared/src/iosMain/IOSSource.kt`:
kotlin
import platform.Foundation.NSURLCredential
class ConnectionCredential(val credentialInfo: NSURLCredential)
I receive a large error message when trying to build the iOS app. Xcode complains that NSURLCredential has been obsolete since Swift 3. I'm unsure how to set up the correct version of Swift or how to properly import from Swift in the iosMain source set.
Any guidance would be greatly appreciated.
Thank you!esdrasdl
10/23/2025, 7:44 PM/Users/esdras/git/exemplos/swift-export-sample/iosApp/ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator18.5.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSURLCredential.h:42:12: 'NSURLCredential' was obsoleted in Swift 3
Using global toolchain override 'Xcode Default'. (in target 'SharedLibrary' from project 'Shared')
Using global toolchain override 'Xcode Default'. (in target 'KotlinRuntime' from project 'Shared')
Using global toolchain override 'Xcode Default'. (in target 'SharedBridge_SwiftExportSampleModuleB' from project 'Shared')
Using global toolchain override 'Xcode Default'. (in target 'SharedBridge_SwiftExportSampleModuleA' from project 'Shared')
Using global toolchain override 'Xcode Default'. (in target 'SharedBridge_Shared' from project 'Shared')
Using global toolchain override 'Xcode Default'. (in target 'SwiftExportSampleModuleB' from project 'Shared')
Using global toolchain override 'Xcode Default'. (in target 'SwiftExportSampleModuleA' from project 'Shared')
--- xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:iOS Simulator, arch:arm64, id:E6E63D0A-9E25-4A1D-AFB7-0552BFC98D89, OS:18.5, name:iPhone 16 }
{ platform:iOS Simulator, arch:x86_64, id:E6E63D0A-9E25-4A1D-AFB7-0552BFC98D89, OS:18.5, name:iPhone 16 }
** BUILD FAILED **
The following build commands failed:
SwiftCompile normal arm64 /Users/esdras/git/exemplos/swift-export-sample/shared/build/SPMPackage/iosSimulatorArm64/Debug/Sources/Shared/Shared.swift (in target 'Shared' from project 'Shared')esdrasdl
10/23/2025, 7:48 PMArtem Olkov
10/27/2025, 9:22 AMNSURLCredential to be a part of your public API? Or is it an internal implementation detail that was accidentally leaked to public api surface?Artem Olkov
10/27/2025, 9:29 AMSwiftBridge and SwiftName when translating types from platform libraries
Ticket for that issueesdrasdl
10/28/2025, 3:04 PMactual class HttpClientEngineProvider(
private val urlCredential: NSURLCredential?,
) {
actual fun provideEngine(): HttpClientEngine =
Darwin.create {
urlCredential?.let {
handleChallenge(MTLSChallengerHandler(urlCredential))
}
}
}
This ChallengerHandle was implemented by MTLSChallengerHandler. Both codes are inside of my iosMainArtem Olkov
10/28/2025, 3:08 PMNSURLCredential is a part of public API.
I'm sorry, this is a bug on the side of swift export, that is more of a feature. We are researching possibilities, how to handle such case, but for now I can only suggest using objective-c export.
And again, thanks for the report!