Closed thanhhoai162963 closed 8 months ago
Unless I miss something, the problem is not really related to Compose Multiplatform. You likely need to carefully go through your code and check what parts get "translated" from swift to kotlin not properly.
For example I see:
@Suppress("CAST_NEVER_SUCCEEDS")
fun String.nsdata(): NSData? {
return (this as NSString).dataUsingEncoding(NSUTF8StringEncoding)
}
If you aim to have a multiplatform solution, then you can't use platform specific types in common code. In this case it's NSData. Kotlin's ByteArray can be an alternative, I think.
If it's not common code, then casting String to NSString, afaik, is incorrect. IDE highlighted that issue, but you suppressed it for some reason - @Suppress("CAST_NEVER_SUCCEEDS")
Closing this as unrelated to Compose Multiplatform.
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.
I try convert triple des from swift code to kotlin mutilplaform but result outputData?.base64EncodedStringWithOptions(options = 0uL = "SpE3b1aZ7MM=") wrong.
In module iosMain:
`@Suppress("CAST_NEVER_SUCCEEDS") fun String.nsdata(): NSData? { return (this as NSString).dataUsingEncoding(NSUTF8StringEncoding) }
fun String.toUTF8String(): String { val bytes = this.toByteArray(Charsets.UTF_8) return bytes.decodeToString() }
@OptIn(ExperimentalEncodingApi::class) actual fun tripleDesEncryptString(input: String, keyRd: String): String? { val inputData = input.toUTF8String().nsdata() val keyData = keyRd.nsdata() val outLength = cValue<ULongVarOf>()
val outputData = NSMutableData.dataWithLength(inputData?.length?.plus(kCCBlockSize3DES) ?: 0uL)
val outLength1 = cValue()
} ` Has anyone ever come across this problem? Hoping for your help