Is there any resources or thoughts on generating c...
# touchlab-tools
j
Is there any resources or thoughts on generating custom Swift code with SKIE? I'm wanting to generate some Swift wrappers for my View Models to properly support generics. (I imagine that direct Swift export will fix that someday, but for now I need workarounds.) I'd be cool if I could write a custom code generator and use SKIE to bundle it with the framework.
k
Is there any resources or thoughts on generating custom Swift code with SKIE?
https://skie.touchlab.co/features/swift-code-bundling
I imagine that direct Swift export will fix that someday
Maybe. Generics are going to be rather difficult to implement. Currently not in scope, although obviously lots of features currently not in scope will be added.
Ah, I should have read that more directly. Generating, not bundling. It's not something that we've talked much about, but you can see an example of that here: https://github.com/touchlab/compose-swift-bridge/
skieSubPlugin
j
Thanks, Kevin! That is a great lead.
Basically, I'm using Orbit MVVM to manage my View Models which defines the state class as a generic parameter on the ViewModel. That makes it hard to then make it conform to ObservableObject because of Objective-C type erasure. So you either need to define the conformance manually for every single view model, or write a wrapper that does most of the observation heavy-lifting and a minimal shim to declare the conformance. Neither is really ideal, but if I could leverage code generation it might make it less painful.
k
Should work, although I would definitely write a few manually to test it out before diving in the code gen part.
👍 1