-
Notifications
You must be signed in to change notification settings - Fork 997
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support for swift codables #3434
Comments
can you elaborate? |
I can, currently resolve takes a dictionary [String:Any] as an argument here:
So I have to make a dictionary even though in reality we dont need a dictionary but a json object (json data/string) shown here:
in ObjC language that was normal, but in Swift it is much better to use structures that conform to Codable (Encodable) so we can have compile time type safety. I made an quick extension for that, but I'm not sure if its the best solution because we still do unnecesary data YOYO-ing because capacitor still requires [String:Any]:
|
BTW call,error() also uses dictionaries, that could be extended to codables |
This makes sense to me and I've had a similar thought. We do support Obj-C but prefer/encourage Swift so adding first-class support for its conventions where we can is valuable. I have started on updating some of the JS<->Native type wrangling here but intend to tackle some bigger refactoring after we have split apart the plugins. The extra serialization proposed here definitely has some drawbacks but I think it should be possible to build in a more efficient solution when updating the related code. I'm adding this to the 3.0 roadmap. |
any update on this guys ? it's really important to have this flexibility i think. |
Are there any downsides of using JSON Encoder? Is it slower? It would save me some headaches if it just worked with |
Any update on supporting Codable in Capacitor? It is definitely less than ideal to not being able to use it in CAPPluginCalls and notifications. Official docs do not mention it, I'm wondering if there is still a plan to support it. If not, it would be good to describe a workaround to be able to use Codable somehow (I'm guessing using |
implemented on #7119 |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out. |
Feature Request
using swift codables for call.resolve()
Description
using swift codables for call.resolve()
Platform(s)
ios
Preferred Solution
using swift codables for call.resolve()
Alternatives
Additional Context
The text was updated successfully, but these errors were encountered: