Closed stevdza-san closed 1 month ago
Hello, @stevdza-san! I've just made a 0.6.2 release which could possibly fix your issue. Please try the new version and let me know if the problem is fixed or not.
@IlyaGulya Thanks for a quick response. I've updated the version and now I'm able to successfully rebuild the project. However, now when I try to import that package, and use the Swift class from Kotlin code, It's not recognized, instead I get some other, non-related properties and stuff:
@stevdza-san you have to mark your declarations public
to be able to access them from kotlin.
For instance, in your case:
import Foundation
import UIKit
@objc public class SMSHandler: NSObject {
@objc public static func sendSms() {
let sms = "sms:+1234567890&body=Hello World."
let strURL = sms.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!
UIApplication.shared.open(URL(string: strURL)!, options: [:], completionHandler: nil)
}
}
@IlyaGulya Hm, I've added the public
keyword on both of them, however when I rebuild the project it's the same thing.
@stevdza-san
Can you provide a reproducer project? π
Ah, I've invalidated and cleared the cache on my IDE. Now it works! Thanks again for your help, I'll probably do a video about this plugin, it's really helpful! Closing this issue now. π
@stevdza-san Hello! There is something strange here... I followed your video tutorial (a really well explained example ππ» ) but my class function (both publics) cannot be used bc it isn't resolved. BUT if I add 'WithData' after fun name works fine π₯Ή
Check my discussion post https://github.com/ttypic/swift-klib-plugin/discussions/41 with my example :)
First of all, thanks for creating such a useful plugin. :) I've been trying to create one simple function in swift that allows me to open up a messaging app and fill in sender/body fields. I'm planing to use that function in
iosMain
source-set inside theactual
declaration. Chat GPT provided the following solution for that logic (Since I'm not that familiar with Swift):This file is placed inside
iosApp/sms
directory.I've included the
swiftklib
plugin in my project, both composeApp-level and project-levelbuild.gradle
files. As far as I understood, in both of thosecreate()
functions, we need to pass a directory name inside which we have declared our Swift file that we're trying to call from Kotlin afterwards. Here's my composeApp-levelbuild.gradle
file:However, when I try to build the project, I do get this error: